Hi Is there a reason why zope.publisher.interfaces.NotFound is not locatable? class NotFound(LookupError, TraversalException): implements(INotFound) def __init__(self, ob, name, request=None): self.ob = ob self.name = name Why should a NotFound error instance not be locatable by default since it provides a location? Regards Roger Ineichen _____________________________ END OF MESSAGE
Roger Ineichen wrote:
Is there a reason why zope.publisher.interfaces.NotFound is not locatable?
class NotFound(LookupError, TraversalException): implements(INotFound)
def __init__(self, ob, name, request=None): self.ob = ob self.name = name
Why should a NotFound error instance not be locatable by default since it provides a location?
What kind of a location does it provide?
Hi Philipp
Betreff: Re: NotFound
Roger Ineichen wrote:
Is there a reason why zope.publisher.interfaces.NotFound is not locatable?
class NotFound(LookupError, TraversalException): implements(INotFound)
def __init__(self, ob, name, request=None): self.ob = ob self.name = name
Why should a NotFound error instance not be locatable by default since it provides a location?
What kind of a location does it provide?
Nothing, the NotFound object is not locatable. but I guess it should, because it contains the real (context) in self.ob. Since the NotFound object doesn't provide a location all viewlets or absolute_utl calls in the same layout template or metal layout slot used by the NotFound page run into a location exception. This makes it impossible to use viewlets as menu items because the NotFound object messes up the real location. I solved that problem with providing a custom NotFound page which uses the self.ob as it's real context: class NotFoundPagelet(browser.BrowserPagelet, NotFound): """NotFound is a view on the real context and not a view on NotFound.""" def __init__(self, context, request): self.context = context.ob self.request = request def render(self): self.request.response.setStatus(404) template = zope.component.getMultiAdapter((self, self.request), IPageTemplate) return template(self) This prevents to mess up the menu items becaues it provides the context which is responsible for running into a NotFound object (e.g. self.context = context.ob). Regards Roger Ineichen
participants (2)
-
Philipp von Weitershausen -
Roger Ineichen