provide 'view/requestUrl' method to be used instead of 'request/URL'

This commit is contained in:
Helmut Merz 2016-06-09 09:03:44 +02:00
parent 8166a0e3c3
commit 8777d1ecdb
2 changed files with 13 additions and 2 deletions

View file

@ -34,7 +34,7 @@
<link rel="icon" type="image/png"
tal:attributes="href string:${resourceBase}favicon.png" />
<base href="." tal:attributes="href request/URL">
<base href="." tal:attributes="href view/requestUrl">
</head>
<body class="tundra"

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
# Copyright (c) 2016 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -27,6 +27,7 @@ from zope.interface import Interface, implements
from zope.cachedescriptors.property import Lazy
from zope import component
from zope.event import notify
from zope.publisher.http import URLGetter as BaseURLGetter
from zope.publisher.interfaces.browser import IBrowserSkinType
from cybertools.browser.renderer import CachableRenderer
@ -63,6 +64,12 @@ class BodyTemplateView(object):
bodyTemplate = UnboundTemplateFile('liquid/body.pt')
class URLGetter(BaseURLGetter):
def __str__(self):
return self.__request.getURL().rstrip('/@@index.html')
class GenericView(object):
index = mainTemplate
@ -103,6 +110,10 @@ class GenericView(object):
# this is useful for a top-level page only
return self.index(*args, **kw)
@property
def requestUrl(self):
return URLGetter(self.request)
@Lazy
def isAuthenticated(self):
return not IUnauthenticatedPrincipal.providedBy(self.request.principal)