provide method for tweaking request/URL, esp remove trailing '/@@index.html'
This commit is contained in:
parent
81ae451969
commit
0d1a37b5d2
1 changed files with 15 additions and 3 deletions
|
@ -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
|
||||
|
@ -18,8 +18,6 @@
|
|||
|
||||
"""
|
||||
Basic view classes for layout-based presentation.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from zope import component
|
||||
|
@ -27,6 +25,7 @@ from zope.interface import Interface, implements
|
|||
from zope.cachedescriptors.property import Lazy
|
||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
from zope.app.security.interfaces import IUnauthenticatedPrincipal
|
||||
from zope.publisher.http import URLGetter as BaseURLGetter
|
||||
|
||||
from cybertools.composer.layout.base import Layout
|
||||
from cybertools.composer.layout.interfaces import ILayoutManager
|
||||
|
@ -54,6 +53,15 @@ class CachableRenderer(object):
|
|||
return rendererTemplate(self.view, view=self.view, macro=self.renderer)
|
||||
|
||||
|
||||
class URLGetter(BaseURLGetter):
|
||||
|
||||
def __str__(self):
|
||||
url = self.__request.getURL()
|
||||
if url.endswith('/@@index.html'):
|
||||
url = url[:-len('/@@index.html')]
|
||||
return url
|
||||
|
||||
|
||||
class BaseView(object):
|
||||
|
||||
template = ViewPageTemplateFile('base.pt')
|
||||
|
@ -73,6 +81,10 @@ class BaseView(object):
|
|||
def __call__(self):
|
||||
return self.template(self)
|
||||
|
||||
@property
|
||||
def requestUrl(self):
|
||||
return URLGetter(self.request)
|
||||
|
||||
@Lazy
|
||||
def authenticated(self):
|
||||
return not IUnauthenticatedPrincipal.providedBy(self.request.principal)
|
||||
|
|
Loading…
Add table
Reference in a new issue