@@ 75,6 75,19 @@ class SubscriptionManager(models.Manager
return subscription
+ def status(self, topic, hub=None, debug=False):
+ config = Config()
+ if hub is None:
+ hub = self._get_hub(topic)
+ headers = config.get_extra_hub_headers(topic, hub)
+
+ try:
+ response = self._send_request(hub+'?hub.mode=status&hub.topic='+topic, {}, headers, debug)
+ except urllib2.HTTPError, e:
+ if e.code == 302:
+ return True
+ return False
+
def subscribe(self, topic, **kwargs):
return self.do_action(topic, mode='subscribe', **kwargs)
@@ 97,12 110,17 @@ class SubscriptionManager(models.Manager
for subvalue in value:
yield key, value
- encoded_data = urlencode(list(data_generator()))
- #headers.update({'Content-Length': (len(encoded_data) + 2)})
- if debug:
- print 'Sending:\n%s\n%s\n%s\n\n' % (url, encoded_data, headers)
+ if data:
+ encoded_data = urlencode(list(data_generator()))
+ #headers.update({'Content-Length': (len(encoded_data) + 2)})
+ if debug:
+ print 'Sending:\n%s\n%s\n%s\n\n' % (url, encoded_data, headers)
+ req = urllib2.Request(url, encoded_data, headers=headers)
+ else:
+ if debug:
+ print 'Sending:\n%s\n%s\n\n' % (url, headers)
+ req = urllib2.Request(url, headers=headers)
- req = urllib2.Request(url, encoded_data, headers=headers)
return urllib2.urlopen(req)