libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1180485 - /libcloud/trunk/libcloud/dns/drivers/zerigo.py
Date Sat, 08 Oct 2011 20:43:54 GMT
Author: tomaz
Date: Sat Oct  8 20:43:54 2011
New Revision: 1180485

URL: http://svn.apache.org/viewvc?rev=1180485&view=rev
Log:
Set a context in the get_record method and default to 0 is x-query-count header is not present.

Modified:
    libcloud/trunk/libcloud/dns/drivers/zerigo.py

Modified: libcloud/trunk/libcloud/dns/drivers/zerigo.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/dns/drivers/zerigo.py?rev=1180485&r1=1180484&r2=1180485&view=diff
==============================================================================
--- libcloud/trunk/libcloud/dns/drivers/zerigo.py (original)
+++ libcloud/trunk/libcloud/dns/drivers/zerigo.py Sat Oct  8 20:43:54 2011
@@ -96,6 +96,9 @@ class ZerigoDNSResponse(Response):
             if context['resource'] == 'zone':
                 raise ZoneDoesNotExistError(value='', driver=self,
                                             zone_id=context['id'])
+            elif context['resource'] == 'record':
+                raise RecordDoesNotExistError(value='', driver=self,
+                                              record_id=context['id'])
         elif status != 503:
             try:
                 body = ET.XML(self.body)
@@ -160,6 +163,7 @@ class ZerigoDNSDriver(DNSDriver):
 
     def get_record(self, zone_id, record_id):
         zone = self.get_zone(zone_id=zone_id)
+        self.connection.set_context({'resource': 'record', 'id': record_id})
         path = API_ROOT + 'hosts/%s.xml' % (record_id)
         data = self.connection.request(path).object
         record = self._to_record(elem=data, zone=zone)
@@ -426,7 +430,7 @@ class ZerigoDNSDriver(DNSDriver):
             transform_func_kwargs['zone'] = value_dict['zone']
 
         exhausted = False
-        result_count = int(response.headers['x-query-count'])
+        result_count = int(response.headers.get('x-query-count', 0))
         transform_func_kwargs['elem'] = response.object
 
         if (params['page'] * ITEMS_PER_PAGE) >= result_count:



Mime
View raw message