Mercurial > libervia-web
view src/pages/blog_new/page_meta.py @ 979:1d558dfb32ca
server: pages redirection:
when using a redirection dict, a new "page" key can be used to redirect to a named page. "args" can be added to specified named arguments to set (will be put in request.args, in addition to existing ones).
The redirection is done dynamically, during the request workflow.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 12 Nov 2017 12:56:46 +0100 |
parents | 96a56856d357 |
children | d042f194624a |
line wrap: on
line source
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- from libervia.server.constants import Const as C from twisted.internet import defer from twisted.words.protocols.jabber import jid from sat.tools.common import data_objects access = C.PAGES_ACCESS_PUBLIC # can be a callable template = u"blog/articles.html" @defer.inlineCallbacks def parse_url(self, request): try: prof_requested = self.nextPath(request) except IndexError: self.pageError(request) template_data = request.template_data target_profile = yield self.host.bridge.profileNameGet(prof_requested) template_data[u'target_profile'] = target_profile target_jid = yield self.host.bridge.asyncGetParamA('JabberID', 'Connection', 'value', profile_key=target_profile) target_jid = jid.JID(target_jid).userhost() template_data[u'target_jid'] = target_jid @defer.inlineCallbacks def prepare_render(self, request): target_jid = request.template_data[u'target_jid'] blog_data = yield self.host.bridge.mbGet( target_jid, "", 10, [], {}, C.SERVICE_PROFILE) request.template_data[u'items'] = data_objects.BlogItems(blog_data)