from zope.publisher.browser import BrowserPage from zope.app.pagetemplate import ViewPageTemplateFile from zope.app.security.interfaces import IUnauthenticatedPrincipal from zope.component import getUtility from krihvel.interfaces import IMembersFolder from zope.traversing.browser import absoluteURL class KrihvelMainIndex(BrowserPage): template = ViewPageTemplateFile('krihvel_main_index.pt') def __call__(self): request = self.request if (not IUnauthenticatedPrincipal.providedBy(request.principal)): members = getUtility(IMembersFolder) member_id = request.principal.id.split('.')[-1] mfolder = members[member_id] mfolder_url = absoluteURL(mfolder, request) request.response.redirect(mfolder_url) else: return self.template()