+ def post(self, user):
+ entries = db.execute("select entry.id,text,ts from user,entry where user.id=entry.userid and user.name=?",(user,))
+
+ self.set_header("Content-Type", 'application/atom+xml')
+ out = self.render_string("templates/feed.xml",
+ user=user,
+ feed_url="{}/user/{}".format(self.settings['domain'], user),
+ hub_url="{}/hub".format(self.settings['domain']),
+ entries=entries,
+ arrow=arrow)
+ #import pdb;pdb.set_trace()
+ subscribers = db.execute("select callback, secret from subscriptions, user where user.id=subscriptions.userid and user.name=?",(user,))
+ for url,secret in subscribers:
+ digest = hmac.new(secret.encode('utf8'), out, digestmod='sha1').hexdigest()
+
+ req = httpclient.HTTPRequest(url=url, allow_nonstandard_methods=True,method='POST', body=out, headers={"X-Hub-Signature":"sha1={}".format(digest),"Content-Type": 'application/atom+xml',"Content-Length":len(out)})
+ apa = httpclient.HTTPClient()
+ apa.fetch(req)
+