Commits

Anonymous committed 49e61f5

Zerigo.list() now returns a dict

Comments (0)

Files changed (2)

tests/test_zerigo_list.py

     account = zerigo.Zerigo()
     zones = account.list()
     if len(zones):
-        print 'Zones list:\n * ' + '\n * '.join([zone.name for zone in zones])
+        print 'Zones list:\n * ' + '\n * '.join(zones.keys())
     else:
         print 'No zones on this account.'
     zerigo.Zerigo._logger.debug('test success')
                                          'Content-Type': 'application/xml'})
         self._conn.add_authorization(restkit.httpc.BasicAuth(self.user, self.password))
 
-    """Return a list of Zone for this account"""
+    """Return a dictionnary of Zone with zonenames in keys for this account"""
     def list(self):
         url = Zerigo._url_api + Zerigo._url_zones
         Zerigo._logger.debug('retrieving ' + url)
 
         tree = ElementTree()
         tree.parse(reply.body_file)
-        list = []
+        list = {}
         zones = tree.getiterator('zone')
         for it in zones:
             name = it.find('domain')
             id = it.find('id')
-            if id is None or name is None:
+            if id is None or name is None or id.text is None or name.text is None:
                 raise ParseError()
-            list.append(Zone(name.text, id.text))
+            list[name.text] = Zone(name.text, id.text)
 
         return list