comparison libervia/pages/u/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 67ec22356457
children f511f8fbbf8a
comparison
equal deleted inserted replaced
1215:f14ab8a25e8b 1216:b2d067339de3
1 #!/usr/bin/env python2.7 1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*- 2 # -*- coding: utf-8 -*-
3 3
4 from libervia.server.constants import Const as C 4 from libervia.server.constants import Const as C
5 from twisted.internet import defer 5 from twisted.internet import defer
6 from twisted.words.protocols.jabber import jid 6 from twisted.words.protocols.jabber import jid
7 7
8 """page used to target a user profile, e.g. for public blog""" 8 """page used to target a user profile, e.g. for public blog"""
9 9
10 name = u"user" 10 name = "user"
11 access = C.PAGES_ACCESS_PUBLIC # can be a callable 11 access = C.PAGES_ACCESS_PUBLIC # can be a callable
12 template = u"blog/articles.html" 12 template = "blog/articles.html"
13 url_cache = True 13 url_cache = True
14 14
15 15
16 @defer.inlineCallbacks 16 @defer.inlineCallbacks
17 def parse_url(self, request): 17 def parse_url(self, request):
21 self.pageError(request) 21 self.pageError(request)
22 22
23 data = self.getRData(request) 23 data = self.getRData(request)
24 24
25 target_profile = yield self.host.bridgeCall("profileNameGet", prof_requested) 25 target_profile = yield self.host.bridgeCall("profileNameGet", prof_requested)
26 request.template_data[u"target_profile"] = target_profile 26 request.template_data["target_profile"] = target_profile
27 target_jid = yield self.host.bridgeCall( 27 target_jid = yield self.host.bridgeCall(
28 "asyncGetParamA", "JabberID", "Connection", "value", profile_key=target_profile 28 "asyncGetParamA", "JabberID", "Connection", "value", profile_key=target_profile
29 ) 29 )
30 target_jid = jid.JID(target_jid) 30 target_jid = jid.JID(target_jid)
31 data[u"service"] = target_jid 31 data["service"] = target_jid
32 32
33 # if URL is parsed here, we'll have atom.xml available and we need to 33 # if URL is parsed here, we'll have atom.xml available and we need to
34 # add the link to the page 34 # add the link to the page
35 atom_url = self.getSubPageURL(request, u'user_blog_feed_atom') 35 atom_url = self.getSubPageURL(request, 'user_blog_feed_atom')
36 request.template_data[u'atom_url'] = atom_url 36 request.template_data['atom_url'] = atom_url
37 request.template_data.setdefault(u'links', []).append({ 37 request.template_data.setdefault('links', []).append({
38 u"href": atom_url, 38 "href": atom_url,
39 u"type": "application/atom+xml", 39 "type": "application/atom+xml",
40 u"rel": "alternate", 40 "rel": "alternate",
41 u"title": "{target_profile}'s blog".format(target_profile=target_profile)}) 41 "title": "{target_profile}'s blog".format(target_profile=target_profile)})
42 42
43 43
44 @defer.inlineCallbacks 44 @defer.inlineCallbacks
45 def prepare_render(self, request): 45 def prepare_render(self, request):
46 data = self.getRData(request) 46 data = self.getRData(request)
47 self.checkCache( 47 self.checkCache(
48 request, C.CACHE_PUBSUB, service=data[u"service"], node=None, short="microblog" 48 request, C.CACHE_PUBSUB, service=data["service"], node=None, short="microblog"
49 ) 49 )
50 self.pageRedirect(u"blog_view", request) 50 self.pageRedirect("blog_view", request)
51 51
52 def on_data_post(self, request): 52 def on_data_post(self, request):
53 return self.getPageByName(u"blog_view").on_data_post(self, request) 53 return self.getPageByName("blog_view").on_data_post(self, request)