------------------------------------------------------------
revno: 33
committer: Florian Fuchs <[email protected]>
branch nick: mailman.client
timestamp: Sat 2012-09-22 18:37:34 +0200
message:
new feature: adding/removing/listing owners and moderators
modified:
mailman/client/_client.py
mailman/client/docs/using.txt
--
lp:mailman.client
https://code.launchpad.net/~mailman-coders/mailman.client/trunk
Your team Mailman Coders is subscribed to branch lp:mailman.client.
To unsubscribe from this branch go to
https://code.launchpad.net/~mailman-coders/mailman.client/trunk/+edit-subscription
=== modified file 'mailman/client/_client.py'
--- mailman/client/_client.py 2012-09-22 15:30:32 +0000
+++ mailman/client/_client.py 2012-09-22 16:37:34 +0000
@@ -309,6 +309,24 @@
self._info = content
@property
+ def owners(self):
+ url = self._url + '/roster/owner'
+ response, content = self._connection.call(url)
+ if 'entries' not in content:
+ return []
+ else:
+ return [item['address'] for item in content['entries']]
+
+ @property
+ def moderators(self):
+ url = self._url + '/roster/moderator'
+ response, content = self._connection.call(url)
+ if 'entries' not in content:
+ return []
+ else:
+ return [item['address'] for item in content['entries']]
+
+ @property
def fqdn_listname(self):
self._get_info()
return self._info['fqdn_listname']
@@ -368,6 +386,28 @@
entries.append(msg)
return entries
+ def add_owner(self, address):
+ self.add_role('owner', address)
+
+ def add_moderator(self, address):
+ self.add_role('moderator', address)
+
+ def add_role(self, role, address):
+ data = dict(list_id=self.list_id,
+ subscriber=address,
+ role=role)
+ self._connection.call('members', data)
+
+ def remove_owner(self, address):
+ self.remove_role('owner', address)
+
+ def remove_moderator(self, address):
+ self.remove_role('moderator', address)
+
+ def remove_role(self, role, address):
+ url = 'lists/%s/%s/%s' % (self.fqdn_listname, role, address)
+ self._connection.call(url, method='DELETE')
+
def moderate_message(self, request_id, action):
"""Moderate a held message.
@@ -471,13 +511,18 @@
if self._info is None:
response, content = self._connection.call(self._url)
self._info = content
-
+
@property
def list_id(self):
self._get_info()
return self._info['list_id']
@property
+ def role(self):
+ self._get_info()
+ return self._info['role']
+
+ @property
def address(self):
self._get_info()
return self._info['address']
=== modified file 'mailman/client/docs/using.txt'
--- mailman/client/docs/using.txt 2012-09-21 19:29:12 +0000
+++ mailman/client/docs/using.txt 2012-09-22 16:37:34 +0000
@@ -347,6 +347,65 @@
True
+Owners and Moderators
+=====================
+
+Owners and moderators are properties of the list object.
+
+ >>> test_one.owners
+ []
+ >>> test_one.moderators
+ []
+
+Owners can be added via the ``add_owner`` method:
+
+ >>> test_one.add_owner('[email protected]')
+ >>> for owner in test_one.owners:
+ ... print owner
+ [email protected]
+
+The owner of the list not automatically added as a member:
+
+ >>> test_one.members
+ [<Member "[email protected]" on "test-one.example.com">]
+
+Moderators can be added similarly:
+
+ >>> test_one.add_moderator('[email protected]')
+ >>> for moderator in test_one.moderators:
+ ... print moderator
+ [email protected]
+
+Moderators are also not automatically added as members:
+
+ >>> test_one.members
+ [<Member "[email protected]" on "test-one.example.com">]
+
+Members and owners/moderators are separate entries in in the general members
+list:
+
+ >>> test_one.subscribe('[email protected]')
+ <Member "[email protected]" on "test-one.example.com">
+
+ >>> for member in client.members:
+ ... print '%s: %s' %(member, member.role)
+ <Member "[email protected]" on "test-one.example.com">: moderator
+ <Member "[email protected]" on "test-one.example.com">: member
+ <Member "[email protected]" on "test-one.example.com">: member
+ <Member "[email protected]" on "test-one.example.com">: owner
+ <Member "[email protected]" on "test-two.example.com">: member
+
+Both owners and moderators can be removed:
+
+ >>> test_one.remove_owner('[email protected]')
+ >>> test_one.owners
+ []
+
+ test_one.remove_moderator('[email protected]')
+ test_one.moderators
+ []
+
+
Moderation
==========
_______________________________________________
Mailman-coders mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-coders