comparison libervia/pages/files/page_meta.py @ 1124:28e3eb3bb217

files reorganisation and installation rework: - files have been reorganised to follow other SàT projects and usual Python organisation (no more "/src" directory) - VERSION file is now used, as for other SàT projects - replace the overcomplicated setup.py be a more sane one. Pyjamas part is not compiled anymore by setup.py, it must be done separatly - removed check for data_dir if it's empty - installation tested working in virtual env - libervia launching script is now in bin/libervia
author Goffi <goffi@goffi.org>
date Sat, 25 Aug 2018 17:59:48 +0200
parents src/pages/files/page_meta.py@cdd389ef97bc
children 29eb15062416
comparison
equal deleted inserted replaced
1123:63a4b8fe9782 1124:28e3eb3bb217
1 #!/usr/bin/env python2.7
2 # -*- coding: utf-8 -*-
3
4 from libervia.server.constants import Const as C
5 from twisted.internet import defer
6 from twisted.words.protocols.jabber import jid
7 from sat.core.log import getLogger
8
9 log = getLogger("pages/files")
10 """files handling pages"""
11
12 name = u"files"
13 access = C.PAGES_ACCESS_PROFILE
14 template = u"file/discover.html"
15
16
17 @defer.inlineCallbacks
18 def prepare_render(self, request):
19 profile = self.getProfile(request)
20 template_data = request.template_data
21 namespace = self.host.ns_map["fis"]
22 entities_services, entities_own, entities_roster = yield self.host.bridgeCall(
23 "discoFindByFeatures", [namespace], [], False, True, True, True, False, profile
24 )
25 tpl_service_entities = template_data["disco_service_entities"] = {}
26 tpl_own_entities = template_data["disco_own_entities"] = {}
27 tpl_roster_entities = template_data["disco_roster_entities"] = {}
28 entities_url = template_data["entities_url"] = {}
29
30 # we store identities in dict of dict using category and type as keys
31 # this way it's easier to test category in the template
32 for tpl_entities, entities_map in (
33 (tpl_service_entities, entities_services),
34 (tpl_own_entities, entities_own),
35 (tpl_roster_entities, entities_roster),
36 ):
37 for entity_str, entity_ids in entities_map.iteritems():
38 entity_jid = jid.JID(entity_str)
39 tpl_entities[entity_jid] = identities = {}
40 for cat, type_, name in entity_ids:
41 identities.setdefault(cat, {}).setdefault(type_, []).append(name)
42 entities_url[entity_jid] = self.getPageByName("files_list").getURL(
43 entity_jid.full()
44 )
45
46
47 def on_data_post(self, request):
48 jid_str = self.getPostedData(request, u"jid")
49 try:
50 jid_ = jid.JID(jid_str)
51 except RuntimeError:
52 self.pageError(request, C.HTTP_BAD_REQUEST)
53 url = self.getPageByName(u"files_list").getURL(jid_.full())
54 self.HTTPRedirect(request, url)