Mercurial > libervia-website
comparison pages/news/page_meta.py @ 6:9ce41ef66dfa
python 3 port
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 05 Oct 2019 01:26:51 +0200 |
parents | 09d66acc7c73 |
children | dc880664a8ec |
comparison
equal
deleted
inserted
replaced
5:9ab2f5b872c7 | 6:9ce41ef66dfa |
---|---|
7 from sat.core.i18n import _ | 7 from sat.core.i18n import _ |
8 from sat.core.log import getLogger | 8 from sat.core.log import getLogger |
9 | 9 |
10 log = getLogger(__name__) | 10 log = getLogger(__name__) |
11 | 11 |
12 name = u"news" | 12 name = "news" |
13 template = u"news/news.html" | 13 template = "news/news.html" |
14 service = None | 14 service = None |
15 node = None | 15 node = None |
16 | 16 |
17 | 17 |
18 @defer.inlineCallbacks | 18 @defer.inlineCallbacks |
19 def prepare_render(self, request): | 19 def prepare_render(self, request): |
20 global service, node | 20 global service, node |
21 if service is None: | 21 if service is None: |
22 blog_dict = self.getConfig(u'news_blog_dict', {}) | 22 blog_dict = self.getConfig('news_blog_dict', {}) |
23 try: | 23 try: |
24 service = jid.JID(blog_dict['service']) | 24 service = jid.JID(blog_dict['service']) |
25 except RuntimeError as e: | 25 except RuntimeError as e: |
26 log.warning(_(u"Can't parse service in news_blog_dict: {e}").format(e=e)) | 26 log.warning(_("Can't parse service in news_blog_dict: {e}").format(e=e)) |
27 service = None | 27 service = None |
28 except KeyError: | 28 except KeyError: |
29 log.warnning(_(u"Missing service in news_blog_dict")) | 29 log.warnning(_("Missing service in news_blog_dict")) |
30 service = None | 30 service = None |
31 node = blog_dict.get('node', u'') | 31 node = blog_dict.get('node', '') |
32 if not blog_dict or service is None: | 32 if not blog_dict or service is None: |
33 log.warning(_(u'No value set for news_blog_dict, "news" page can\'t be used')) | 33 log.warning(_('No value set for news_blog_dict, "news" page can\'t be used')) |
34 self.pageError(request, C.HTTP_SERVICE_UNAVAILABLE) | 34 self.pageError(request, C.HTTP_SERVICE_UNAVAILABLE) |
35 | 35 |
36 data = self.getRData(request) | 36 data = self.getRData(request) |
37 data[u'service'] = service | 37 data['service'] = service |
38 data[u'node'] = node | 38 data['node'] = node |
39 | 39 |
40 # self.checkCache( | 40 # self.checkCache( |
41 # request, C.CACHE_PUBSUB, service=service, node=node, short="microblog") | 41 # request, C.CACHE_PUBSUB, service=service, node=node, short="microblog") |
42 | 42 |
43 # we now need blog items, using blog common page | 43 # we now need blog items, using blog common page |
44 # this will fill the "items" template data | 44 # this will fill the "items" template data |
45 blog_page = self.getPageByName(u"blog_view") | 45 blog_page = self.getPageByName("blog_view") |
46 yield blog_page.prepare_render(self, request) | 46 yield blog_page.prepare_render(self, request) |