------------------------------------------------------------
revno: 40
committer: Florian Fuchs <[email protected]>
branch nick: mailman.client
timestamp: Tue 2013-03-19 10:27:11 -0700
message:
  added setup dependency
modified:
  setup.py
  src/mailmanclient/_client.py
  src/mailmanclient/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 'setup.py'
--- setup.py	2013-03-15 23:02:04 +0000
+++ setup.py	2013-03-19 17:27:11 +0000
@@ -45,5 +45,5 @@
     # Auto-conversion to Python 3.
     use_2to3=True,
     convert_2to3_doctests=find_doctests(),
-    install_requires=['httplib2'],
+    install_requires=['httplib2', 'mock', ],
 )

=== modified file 'src/mailmanclient/_client.py'
--- src/mailmanclient/_client.py	2013-03-17 18:17:30 +0000
+++ src/mailmanclient/_client.py	2013-03-19 17:27:11 +0000
@@ -575,7 +575,7 @@
     @property
     def user(self):
         self._get_info()
-        return self._info['user']
+        return _User(self._connection, self._info['user'])
 
     def unsubscribe(self):
         """Unsubscribe the member from a mailing list.
@@ -642,7 +642,10 @@
 
     @property
     def preferences(self):
-        return _Preferences(self._connection, self.address)
+        if self._preferences is None:
+            path = 'users/{0}/preferences'.format(self.user_id)
+            self._preferences = _Preferences(self._connection, path)
+        return self._preferences
 
     def save(self):
         data = {'display_name': self.display_name}
@@ -722,19 +725,16 @@
 
 
 class _Preferences:
-    def __init__(self, connection, address):
+    def __init__(self, connection, path):
         self._connection = connection
-        self._address = address
+        self._path = path
         self._preferences = None
         self._get_preferences()
 
     def _get_preferences(self):
         if self._preferences is None:
-            response, content = self._connection.call(
-                'addresses/{0}/preferences'.format(self._address))
-            if 'entries' not in content:
-                self._preferences = []
-            self._preferences = content['entries']
+            response, content = self._connection.call(self._path)
+            self._preferences = content
 
     def __iter__(self):
         for preference in self._preferences:
@@ -750,7 +750,7 @@
                         'volume', 'web_host',)
 
 
-class _Settings():
+class _Settings:
     def __init__(self, connection, url):
         self._connection = connection
         self._url = url

=== modified file 'src/mailmanclient/docs/using.txt'
--- src/mailmanclient/docs/using.txt	2013-03-15 23:02:04 +0000
+++ src/mailmanclient/docs/using.txt	2013-03-19 17:27:11 +0000
@@ -212,15 +212,18 @@
 
 We can get a single membership too.
 
-    >>> cris = test_two.get_member('[email protected]')
-    >>> cris
+    >>> cris_test_two = test_two.get_member('[email protected]')
+    >>> cris_test_two
     <Member "[email protected]" on "test-two.example.com">
-    >>> print cris.role
+    >>> print cris_test_two.role
     member
-    >>> print cris.self_link
+    >>> print cris_test_two.self_link
     http://localhost:8001/3.0/members/...
-    >>> print cris.user
-    http://localhost:8001/3.0/users/...
+
+The membership object's ``user`` attribute will return a User object:
+
+    >>> cris_test_two.user 
+    <User "Cris" (...)>
 
 If you use an address which is not a member of test_two `ValueError` is raised:
 
@@ -241,7 +244,7 @@
 
 A little later, Cris decides to unsubscribe from the Test Two mailing list.
 
-    >>> cris.unsubscribe()
+    >>> cris_test_two.unsubscribe()
     >>> for member in client.members:
     ...     print member
     <Member "[email protected]" on "test-one.example.com">

_______________________________________________
Mailman-coders mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-coders

Reply via email to