------------------------------------------------------------
revno: 6753
committer: Barry Warsaw <[email protected]>
branch nick: 3.0
timestamp: Sat 2009-07-25 00:23:01 -0400
message:
  * Expose IMailingLists in the API.
  * Better titles in the IMailingList interface.
  * Expose the real_name attribute.
  * Refactor URL mappers.
modified:
  src/mailman/interfaces/mailinglist.py
  src/mailman/rest/configure.zcml
  src/mailman/rest/docs/lists.txt
  src/mailman/rest/urls.py


--
lp:mailman
https://code.launchpad.net/~mailman-coders/mailman/3.0

Your team Mailman Checkins is subscribed to branch lp:mailman.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/3.0/+edit-subscription.
=== modified file 'src/mailman/interfaces/mailinglist.py'
--- src/mailman/interfaces/mailinglist.py	2009-07-11 01:55:26 +0000
+++ src/mailman/interfaces/mailinglist.py	2009-07-25 04:23:01 +0000
@@ -76,7 +76,7 @@
     # List identity
 
     list_name = exported(TextLine(
-        title=_("The mailing list's short name"),
+        title=_('Short name'),
         description=_("""\
         The read-only short name of the mailing list.  Note that where a
         Mailman installation supports multiple domains, this short name may
@@ -87,7 +87,7 @@
         """)))
 
     host_name = exported(TextLine(
-        title=_("The mailing list's host name"),
+        title=_('Host name'),
         description=_("""\
         The read-only domain name 'hosting' this mailing list.  This is always
         the domain name part of the posting email address, and it may bear no
@@ -97,7 +97,7 @@
         """)))
 
     fqdn_listname = exported(TextLine(
-        title=_("The mailing list's filly qualified name"),
+        title=_('Fully qualified list name'),
         description=_("""\
         The read-only fully qualified name of the mailing list.  This is the
         guaranteed unique id for the mailing list, and it is always the
@@ -105,12 +105,14 @@
         always comprised of the list_name + '@' + host_name.
         """)))
 
-    real_name = Attribute(
-        """The short human-readable descriptive name for the mailing list.  By
+    real_name = exported(TextLine(
+        title=_('Real name'),
+        description=_("""\
+        The short human-readable descriptive name for the mailing list.  By
         default, this is the capitalized `list_name`, but it can be changed to
         anything.  This is used in locations such as the message footers and
         Subject prefix.
-        """)
+        """)))
 
     list_id = Attribute(
         """The RFC 2919 List-ID header value.""")

=== modified file 'src/mailman/rest/configure.zcml'
--- src/mailman/rest/configure.zcml	2009-07-21 03:13:59 +0000
+++ src/mailman/rest/configure.zcml	2009-07-25 04:23:01 +0000
@@ -34,6 +34,13 @@
     factory="mailman.rest.urls.FallbackURLMapper"
     />
 
+  <adapter
+    for="mailman.interfaces.mailinglist.IMailingList
+         mailman.rest.webservice.AdminWebServiceRequest"
+    provides="zope.traversing.browser.interfaces.IAbsoluteURL"
+    factory="mailman.rest.urls.MailingListURLMapper"
+    />
+
   <utility
     factory="mailman.rest.configuration.AdminWebServiceConfiguration"
     provides="lazr.restful.interfaces.IWebServiceConfiguration">

=== modified file 'src/mailman/rest/docs/lists.txt'
--- src/mailman/rest/docs/lists.txt	2009-07-21 03:13:59 +0000
+++ src/mailman/rest/docs/lists.txt	2009-07-25 04:23:01 +0000
@@ -10,3 +10,23 @@
     resource_type_link: http://localhost:8001/3.0/#mailing_lists
     start: None
     total_size: 0
+
+Create a mailing list in a domain and it's accessible via the API.
+
+    >>> from mailman.app.lifecycle import create_list
+    >>> create_list('[email protected]')
+    <mailing list "[email protected]" at ...>
+    >>> transaction.commit()
+
+    >>> dump_json('http://localhost:8001/3.0/lists')
+    entry 0:
+        fqdn_listname: [email protected]
+        host_name: example.com
+        http_etag: "..."
+        list_name: test-one
+        real_name: Test-one
+        resource_type_link: http://localhost:8001/3.0/#mailing_list
+        self_link: http://localhost:8001/3.0/mailing_lists/[email protected]
+    resource_type_link: http://localhost:8001/3.0/#mailing_lists
+    start: 0
+    total_size: 1

=== modified file 'src/mailman/rest/urls.py'
--- src/mailman/rest/urls.py	2009-07-11 01:55:26 +0000
+++ src/mailman/rest/urls.py	2009-07-25 04:23:01 +0000
@@ -21,8 +21,8 @@
 
 __metaclass__ = type
 __all__ = [
-    'AbsoluteURLMapper',
     'DomainURLMapper',
+    'MailingListURLMapper',
     ]
 
 
@@ -82,19 +82,35 @@
             return ''
         urls = {
             system: 'system',
-            #config.db.list_manager: 'lists',
+            config.db.list_manager: 'lists',
             }
         return urls[ob]
 
 
 
-class DomainURLMapper(BasicURLMapper):
+class TopLevelURLMapper(BasicURLMapper):
+    """A simple mapper for top level objects."""
+
+    implements(IAbsoluteURL)
+
+    format_string = None
+
+    def __call__(self):
+        """Return the hard-coded URL to the resource."""
+        return self.format_string.format(self)
+
+
+class DomainURLMapper(TopLevelURLMapper):
     """Mapper of `IDomains` to `IAbsoluteURL`."""
 
-    implements(IAbsoluteURL)
-
-    def __call__(self):
-        """Return the hard-coded URL to the domain."""
-        return ('{0.schema}://{0.hostname}:{0.port}/{0.version}/domains/'
-                '{1.email_host}').format(self, self.context)
-        
+    format_string = (
+        '{0.schema}://{0.hostname}:{0.port}/{0.version}/'
+        'domains/{0.context.email_host}')
+
+
+class MailingListURLMapper(TopLevelURLMapper):
+    """Mapper of `IMailingList` to `IAbsoluteURL`."""
+
+    format_string = (
+        '{0.schema}://{0.hostname}:{0.port}/{0.version}/'
+        'mailing_lists/{0.context.fqdn_listname}')

_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to