Mercurial > libervia-web
comparison libervia/pages/files/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 | 29eb15062416 |
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 from sat.core.log import getLogger | 7 from sat.core.log import getLogger |
8 | 8 |
9 log = getLogger(__name__) | 9 log = getLogger(__name__) |
10 """files handling pages""" | 10 """files handling pages""" |
11 | 11 |
12 name = u"files" | 12 name = "files" |
13 access = C.PAGES_ACCESS_PROFILE | 13 access = C.PAGES_ACCESS_PROFILE |
14 template = u"file/discover.html" | 14 template = "file/discover.html" |
15 | 15 |
16 | 16 |
17 @defer.inlineCallbacks | 17 @defer.inlineCallbacks |
18 def prepare_render(self, request): | 18 def prepare_render(self, request): |
19 profile = self.getProfile(request) | 19 profile = self.getProfile(request) |
32 for tpl_entities, entities_map in ( | 32 for tpl_entities, entities_map in ( |
33 (tpl_service_entities, entities_services), | 33 (tpl_service_entities, entities_services), |
34 (tpl_own_entities, entities_own), | 34 (tpl_own_entities, entities_own), |
35 (tpl_roster_entities, entities_roster), | 35 (tpl_roster_entities, entities_roster), |
36 ): | 36 ): |
37 for entity_str, entity_ids in entities_map.iteritems(): | 37 for entity_str, entity_ids in entities_map.items(): |
38 entity_jid = jid.JID(entity_str) | 38 entity_jid = jid.JID(entity_str) |
39 tpl_entities[entity_jid] = identities = {} | 39 tpl_entities[entity_jid] = identities = {} |
40 for cat, type_, name in entity_ids: | 40 for cat, type_, name in entity_ids: |
41 identities.setdefault(cat, {}).setdefault(type_, []).append(name) | 41 identities.setdefault(cat, {}).setdefault(type_, []).append(name) |
42 entities_url[entity_jid] = self.getPageByName("files_list").getURL( | 42 entities_url[entity_jid] = self.getPageByName("files_list").getURL( |
43 entity_jid.full() | 43 entity_jid.full() |
44 ) | 44 ) |
45 | 45 |
46 | 46 |
47 def on_data_post(self, request): | 47 def on_data_post(self, request): |
48 jid_str = self.getPostedData(request, u"jid") | 48 jid_str = self.getPostedData(request, "jid") |
49 try: | 49 try: |
50 jid_ = jid.JID(jid_str) | 50 jid_ = jid.JID(jid_str) |
51 except RuntimeError: | 51 except RuntimeError: |
52 self.pageError(request, C.HTTP_BAD_REQUEST) | 52 self.pageError(request, C.HTTP_BAD_REQUEST) |
53 url = self.getPageByName(u"files_list").getURL(jid_.full()) | 53 url = self.getPageByName("files_list").getURL(jid_.full()) |
54 self.HTTPRedirect(request, url) | 54 self.HTTPRedirect(request, url) |