Merge authors:
  benste (benste)
------------------------------------------------------------
revno: 15 [merge]
fixes bug(s): https://launchpad.net/bugs/802540
committer: Florian Fuchs <[email protected]>
branch nick: mailman.client
timestamp: Mon 2011-08-08 08:49:20 +0200
message:
  Added benste's fix for lp:802540 with some minor changes:
  Domains can now be retrieved not only by their mail_host property but also
  their web host (base_uri)
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	2011-05-30 07:14:15 +0000
+++ mailman/client/_client.py	2011-08-08 06:49:20 +0000
@@ -179,10 +179,19 @@
         response, content = self._connection.call('domains', data)
         return _Domain(self._connection, response['location'])
 
-    def get_domain(self, email_host):
-        response, content = self._connection.call(
-            'domains/{0}'.format(email_host))
-        return _Domain(self._connection, content['self_link'])
+    def get_domain(self, email_host=None, web_host=None):
+        """Get domain by its email_host or its web_host."""
+        if email_host is not None:
+            response, content = self._connection.call(
+                'domains/{0}'.format(email_host))
+            return _Domain(self._connection, content['self_link'])
+        if web_host is not None:
+            for domain in self.domains:
+                # note: `base_url` property will be renamed to `web_host`
+                # in Mailman3Alpha8
+                if domain.base_url == web_host:
+                    return domain
+            return self.get_domain("no-domain")
 
     def get_list(self, fqdn_listname):
         response, content = self._connection.call(
@@ -209,6 +218,8 @@
             response, content = self._connection.call(self._url)
             self._info = content
 
+    # note: `base_url` property will be renamed to `web_host`
+    # in Mailman3Alpha8
     @property
     def base_url(self):
         self._get_info()

=== modified file 'mailman/client/docs/using.txt'
--- mailman/client/docs/using.txt	2011-06-20 06:55:25 +0000
+++ mailman/client/docs/using.txt	2011-08-08 06:49:20 +0000
@@ -50,13 +50,21 @@
     >>> print example_dot_com.url_host
     example.com
 
-You can also get an existing domain independently.
+You can also get an existing domain independently using its mail host.
 
     >>> example = client.get_domain('example.com')
     >>> example
     <Domain "example.com">
     >>> print example_dot_com.base_url
     http://example.com
+    
+Additionally you can get an existing domain using its web host. 
+
+    >>> example = client.get_domain(None,'example.com')
+    >>> example
+    <Domain "example.com">
+    >>> print example_dot_com.base_url
+    http://example.com
 
 But you cannot retrieve a non-existent domain.
 

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

Reply via email to