Mercurial > libervia-web
view src/pages/u/page_meta.py @ 962:c7fba7709d05
Pages: various improvments:
- automatic confirmation message on data post can now be avoided by using the C.POST_NO_CONFIRM flag
- new tailing_slash page variable can be used to force a trailing slash at the end of the URL (by redirecting if necessary)
- LiberviaPage now has a url attribute with the its relative path
- new redirection methods:
- getPageRedirectURL: generate and URL which will redirect to current page (or somewhere else), mainly useful for login
- HTTPRedirect: stop workflow and do a HTTP redirection
- redirectOrContinue: redirect a page if redirect arguments is present (usually redirect_url), else continue workflow
- profile access now redirect to login page if registration is allowed.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 27 Oct 2017 18:43:16 +0200 |
parents | 2345577da5ca |
children | 1c9b6d2c30b5 |
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 """page used to target a user profile, e.g. for public blog""" name = u"user" 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) data = self.getRData(request) target_profile = yield self.host.bridge.profileNameGet(prof_requested) request.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) data[u'service'] = target_jid @defer.inlineCallbacks def prepare_render(self, request): self.pageRedirect(u'blog', request)