------------------------------------------------------------
revno: 34
committer: Florian Fuchs <[email protected]>
branch nick: mailman.client
timestamp: Sun 2012-09-23 22:52:30 +0200
message:
* added user creation/editing
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 16:37:34 +0000
+++ mailman/client/_client.py 2012-09-23 20:52:30 +0000
@@ -221,6 +221,12 @@
else:
return None
+ def create_user(self, email, password, display_name=''):
+ response, content = self._connection.call(
+ 'users', dict(email=email, password=password,
+ display_name=display_name))
+ return _User(self._connection, response['location'])
+
def get_user(self, address):
response, content = self._connection.call(
'users/{0}'.format(address))
@@ -557,6 +563,7 @@
self._info = None
self._addresses = None
self._preferences = None
+ self._cleartext_password = None
def __repr__(self):
return '<User "{0}" ({1})>'.format(
@@ -576,6 +583,19 @@
self._get_info()
return self._info.get('display_name', None)
+ @display_name.setter
+ def display_name(self, value):
+ self._info['display_name'] = value
+
+ @property
+ def password(self):
+ self._get_info()
+ return self._info.get('password', None)
+
+ @password.setter
+ def password(self, value):
+ self._cleartext_password = value
+
@property
def user_id(self):
self._get_info()
@@ -595,6 +615,14 @@
def preferences(self):
return _Preferences(self._connection, self.address)
+ def save(self):
+ data = {'display_name': self.display_name}
+ if self._cleartext_password is not None:
+ data['cleartext_password'] = self._cleartext_password
+ self.cleartext_password = None
+ response, content = self._connection.call(self._url,
+ data, method='PATCH')
+ self._info = None
class _Addresses:
def __init__(self, connection, user_id):
@@ -697,5 +725,3 @@
if attribute not in LIST_READ_ONLY_ATTRS:
data[attribute] = value
response, content = self._connection.call(self._url, data, 'PATCH')
-
-
=== modified file 'mailman/client/docs/using.txt'
--- mailman/client/docs/using.txt 2012-09-22 16:37:34 +0000
+++ mailman/client/docs/using.txt 2012-09-23 20:52:30 +0000
@@ -282,6 +282,37 @@
Cris
...
+Users can be added using ``create_user``. The display_name is optional:
+ >>> client.create_user(email='[email protected]',
+ ... password='somepass',
+ ... display_name='Ler')
+ <User "Ler" (...)>
+ >>> ler = client.get_user('[email protected]')
+ >>> print ler.password
+ $...
+ >>> print ler.display_name
+ Ler
+
+User attributes can be changed through assignment, but you need to call the
+object's ``save`` method to store the changes in the mailman core database.
+
+ >>> ler.display_name = 'Sir Ler'
+ >>> ler.save()
+ >>> ler = client.get_user('[email protected]')
+ >>> print ler.display_name
+ Sir Ler
+
+Passwords can be changed as well:
+
+ >>> old_pwd = ler.password
+ >>> ler.password = 'easy'
+ >>> old_pwd == ler.password
+ True
+ >>> ler.save()
+ >>> old_pwd == ler.password
+ False
+
+
List Settings
=============
_______________________________________________
Mailman-coders mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-coders