Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Dev

NotFound

 

 

Zope dev RSS feed   Index | Next | Previous | View Threaded


dev at projekt01

May 10, 2008, 4:15 PM

Post #1 of 3 (59 views)
Permalink
NotFound

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

_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


philipp at weitershausen

May 13, 2008, 10:21 AM

Post #2 of 3 (38 views)
Permalink
Re: NotFound [In reply to]

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?
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


dev at projekt01

May 13, 2008, 6:31 PM

Post #3 of 3 (31 views)
Permalink
AW: NotFound [In reply to]

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

_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Zope dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.