# HG changeset patch # User Goffi # Date 1492454650 -7200 # Node ID e4c13a995e0b1fb64936360389ad2029f564da64 # Parent af6a62e210531035ac5b5dedf3d966549de28280 pages (common/blog): data post (i.e. new comments) is now handled diff -r af6a62e21053 -r e4c13a995e0b src/pages/common/blog/page_meta.py --- a/src/pages/common/blog/page_meta.py Mon Apr 17 20:43:12 2017 +0200 +++ b/src/pages/common/blog/page_meta.py Mon Apr 17 20:44:10 2017 +0200 @@ -95,3 +95,22 @@ template_data = request.template_data template_data[u'items'] = items + template_data[u'allow_commenting'] = u'simple' + + +@defer.inlineCallbacks +def on_data_post(self, request): + profile = self.getProfile(request) + if profile is None: + self.pageError(request, C.HTTP_UNAUTHORIZED) + service, node, body = self.getPostedData(request, (u'service', u'node', u'body')) + if not body: + self.pageError(request, C.HTTP_BAD_REQUEST) + comment_data = {u"content": body} + try: + yield self.host.bridge.mbSend(service, node, comment_data, profile) + except Exception as e: + if u"forbidden" in unicode(e): + self.pageError(request, 401) + else: + raise e