Commits

Peter Sanchez committed ad3c6f8

Added NSHost support to NSZone class

  • Participants
  • Parent commits dfbf174

Comments (0)

Files changed (1)

     
 
 class ZerigoDNS(object):
+    ''' Base class to interact with ZerigoDNS API.
+    '''
     vals = {}
     def __init__(self, user, key, data=None, is_secure=True, is_debug=False):
         self.api_host = 'ns.zerigo.com'
         )
         self.element = 'zones'
     
+    def __setattr__(self, name, val):
+        if name == 'hosts' and isinstance(val, (list, tuple)):
+            # Add hosts as NSHost objects
+            self.vals[name] = [
+                NSHost(
+                    self.user,
+                    self.key,
+                    data=zdata['host'],
+                    is_secure=self.is_secure,
+                    is_debug=self.is_debug,
+                ) for zdata in val
+            ]
+        else:
+            super(NSZone, self).__setattr__(name, val)
+    
     def to_xml(self):
         return self._to_xml({'zone': self.get_xml_data()})