Sneha Priscilla has proposed merging
lp:~stylistica/mailman.client/user_preferences into lp:mailman.client.
Requested reviews:
Florian Fuchs (flo-fuchs)
For more details, see:
https://code.launchpad.net/~stylistica/mailman.client/user_preferences/+merge/188950
Made changes to the Mailman client file with respect to my user preferences
GSoC project.
Brief Summary: Added a read only attributes list for preferences , added
preferences for Address object which was missing
--
https://code.launchpad.net/~stylistica/mailman.client/user_preferences/+merge/188950
Your team Mailman Coders is subscribed to branch lp:mailman.client.
=== modified file 'src/mailmanclient/_client.py'
--- src/mailmanclient/_client.py 2013-03-22 18:28:16 +0000
+++ src/mailmanclient/_client.py 2013-10-02 22:19:26 +0000
@@ -43,11 +43,13 @@
class MailmanConnectionError(Exception):
+
"""Custom Exception to catch connection errors."""
pass
class _Connection:
+
"""A connection to the REST client."""
def __init__(self, baseurl, name=None, password=None):
@@ -122,6 +124,7 @@
class Client:
+
"""Access the Mailman REST API root."""
def __init__(self, baseurl, name=None, password=None):
@@ -248,8 +251,9 @@
response, content = self._connection.call(
'lists/{0}'.format(fqdn_listname), None, 'DELETE')
-
+
class _Domain:
+
def __init__(self, connection, url):
self._connection = connection
self._url = url
@@ -308,6 +312,7 @@
class _List:
+
def __init__(self, connection, url, data=None):
self._connection = connection
self._url = url
@@ -538,6 +543,7 @@
class _Member:
+
def __init__(self, connection, url):
self._connection = connection
self._url = url
@@ -594,6 +600,7 @@
class _User:
+
def __init__(self, connection, url):
self._connection = connection
self._url = url
@@ -656,11 +663,11 @@
subscriptions = []
for address in self.addresses:
response, content = self._connection.call('members/find',
- data={'subscriber': address})
+ data={'subscriber': address})
try:
for entry in content['entries']:
subscriptions.append(_Member(self._connection,
- entry['self_link']))
+ entry['self_link']))
except KeyError:
pass
self._subscriptions = subscriptions
@@ -696,6 +703,7 @@
class _Addresses:
+
def __init__(self, connection, user_id):
self._connection = connection
self._user_id = user_id
@@ -719,9 +727,11 @@
class _Address:
+
def __init__(self, connection, address):
self._connection = connection
self._address = address
+ self._preferences = None
self._url = address['self_link']
self._info = None
@@ -748,6 +758,13 @@
self._get_info()
return self._info.get('verified_on')
+ @property
+ def preferences(self):
+ if self._preferences is None:
+ path = 'addresses/{0}/preferences'.format(self._address['email'])
+ self._preferences = _Preferences(self._connection, path)
+ return self._preferences
+
def verify(self):
self._connection.call('addresses/{0}/verify'
.format(self._address['email']), method='POST')
@@ -768,8 +785,11 @@
'receive_list_copy',
'receive_own_postings', )
+PREF_READ_ONLY_ATTRS = ('http_etag', 'self_link')
+
class _Preferences:
+
def __init__(self, connection, url):
self._connection = connection
self._url = url
@@ -789,7 +809,7 @@
def __setitem__(self, key, value):
self._preferences[key] = value
-
+
def __getitem__(self, key):
return self._preferences[key]
@@ -812,9 +832,9 @@
def save(self):
data = {}
for key in self._preferences:
- if self._preferences[key] is not None:
+ if key not in PREF_READ_ONLY_ATTRS and self._preferences[key] is not None:
data[key] = self._preferences[key]
- response, content = self._connection.call(self._url, data, 'PUT')
+ response, content = self._connection.call(self._url, data, 'PATCH')
LIST_READ_ONLY_ATTRS = ('bounces_address', 'created_at', 'digest_last_sent_at',
@@ -827,6 +847,7 @@
class _Settings:
+
def __init__(self, connection, url):
self._connection = connection
self._url = url
@@ -872,6 +893,7 @@
class _Page:
+
def __init__(self, connection, path, model, count=DEFAULT_PAGE_ITEM_COUNT,
page=1):
self._connection = connection
_______________________________________________
Mailman-coders mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mailman-coders