view src/pages/u/page_meta.py @ 1021:b39c527f208c

pages (tickets): check cache in prepare_render instead of parse_url
author Goffi <goffi@goffi.org>
date Sun, 21 Jan 2018 13:17:21 +0100
parents 1c9b6d2c30b5
children f82c355ffa6e
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"
url_cache = True


@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)