Mercurial > libervia-web
diff libervia/pages/forums/topics/page_meta.py @ 1216:b2d067339de3
python 3 port:
/!\ Python 3.6+ is now needed to use libervia
/!\ instability may occur and features may not be working anymore, this will improve with time
/!\ TxJSONRPC dependency has been removed
The same procedure as in backend has been applied (check backend commit ab2696e34d29 logs
for details). Removed now deprecated code (Pyjamas compiled browser part, legacy blog,
JSON RPC related code).
Adapted code to work without `html` and `themes` dirs.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 13 Aug 2019 19:12:31 +0200 |
parents | 0f37b65fe7c2 |
children | f511f8fbbf8a |
line wrap: on
line diff
--- a/libervia/pages/forums/topics/page_meta.py Tue Aug 13 09:39:33 2019 +0200 +++ b/libervia/pages/forums/topics/page_meta.py Tue Aug 13 19:12:31 2019 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- from libervia.server.constants import Const as C @@ -9,37 +9,37 @@ log = getLogger(__name__) -name = u"forum_topics" +name = "forum_topics" access = C.PAGES_ACCESS_PUBLIC -template = u"forum/view_topics.html" +template = "forum/view_topics.html" def parse_url(self, request): - self.getPathArgs(request, ["service", "node"], 2, service=u"jid") + self.getPathArgs(request, ["service", "node"], 2, service="jid") @defer.inlineCallbacks def prepare_render(self, request): profile = self.getProfile(request) or C.SERVICE_PROFILE data = self.getRData(request) - service, node = data[u"service"], data[u"node"] - request.template_data.update({u"service": service, u"node": node}) + service, node = data["service"], data["node"] + request.template_data.update({"service": service, "node": node}) template_data = request.template_data topics, metadata = yield self.host.bridgeCall( - u"forumTopicsGet", service.full(), node, {}, profile + "forumTopicsGet", service.full(), node, {}, profile ) - template_data[u"identities"] = identities = {} + template_data["identities"] = identities = {} for topic in topics: - parsed_uri = xmpp_uri.parseXMPPUri(topic[u"uri"]) - author = topic[u"author"] - topic[u"http_uri"] = self.getPageByName(u"forum_view").getURL( - parsed_uri[u"path"], parsed_uri[u"node"] + parsed_uri = xmpp_uri.parseXMPPUri(topic["uri"]) + author = topic["author"] + topic["http_uri"] = self.getPageByName("forum_view").getURL( + parsed_uri["path"], parsed_uri["node"] ) if author not in identities: - identities[topic[u"author"]] = yield self.host.bridgeCall( - u"identityGet", author, profile + identities[topic["author"]] = yield self.host.bridgeCall( + "identityGet", author, profile ) - template_data[u"topics"] = topics + template_data["topics"] = topics @defer.inlineCallbacks @@ -47,23 +47,23 @@ profile = self.getProfile(request) if profile is None: self.pageError(request, C.HTTP_FORBIDDEN) - type_ = self.getPostedData(request, u"type") - if type_ == u"new_topic": + type_ = self.getPostedData(request, "type") + if type_ == "new_topic": service, node, title, body = self.getPostedData( - request, (u"service", u"node", u"title", u"body") + request, ("service", "node", "title", "body") ) if not title or not body: self.pageError(request, C.HTTP_BAD_REQUEST) - topic_data = {u"title": title, u"content": body} + topic_data = {"title": title, "content": body} try: yield self.host.bridgeCall( - u"forumTopicCreate", service, node, topic_data, profile + "forumTopicCreate", service, node, topic_data, profile ) except Exception as e: - if u"forbidden" in unicode(e): + if "forbidden" in str(e): self.pageError(request, 401) else: raise e else: - log.warning(_(u"Unhandled data type: {}").format(type_)) + log.warning(_("Unhandled data type: {}").format(type_))