[Zope-dev] Path Handler problems

Chris Withers chrisw@nipltd.com
Thu, 26 Oct 2000 17:46:05 +0100


Hi,

I've finally gotten around to doing the PathHandler product I mentioned
ages ago and now I've run into problems.

Since it's so short, here's the product class:

class PathHandler( SimpleItem,Persistent,Acquisition.Implicit ): 

    meta_type = 'Path Handler' 

    def __init__(self, id, method_name, title=''): 
        """initialise a new instance of Path Handler"""
        self.id = id
        self.title = title
        self.method_name= method_name

    def __bobo_traverse__(self, TraversalRequest, name):
        list=copy(TraversalRequest['TraversalRequestNameStack'])
        list.reverse()
        TraversalRequest['path_to_handle']=[name]+list
        TraversalRequest['TraversalRequestNameStack']=[]

        return getattr(self,self.method_name)

Okay, the confusing bit first. Let's say x is an instance of
PathHandler, with method_name = 'the_method'.
the_method is a DTML method as follows:

<dtml-var standard_html_header>
<h2><dtml-var title_or_id> <dtml-var document_title></h2>
<p>
<dtml-var path_to_handle>
</p>
<dtml-var standard_html_footer>

If I try the url:
http://localhost:7080/x
...I get:
Resource not found
<!--
PathHandler instance at 011F5500
-->
Traceback (innermost last):
  File E:\Zope\2271B4~1.2\lib\python\ZPublisher\Publish.py, line 222, in
publish_module
  File E:\Zope\2271B4~1.2\lib\python\ZPublisher\Publish.py, line 187, in
publish
  File E:\Zope\2271B4~1.2\lib\python\Zope\__init__.py, line 221, in
zpublisher_exception_hook
    (Object: ApplicationDefaultPermissions)
  File E:\Zope\2271B4~1.2\lib\python\ZPublisher\Publish.py, line 173, in
publish
  File E:\Zope\2271B4~1.2\lib\python\ZPublisher\HTTPResponse.py, line
308, in setBody
  File E:\Zope\2271B4~1.2\lib\python\ZPublisher\HTTPResponse.py, line
529, in notFoundError
NotFound: (see above)

If I try the url:
http://localhost:7080/x/1
...I get what I expect, the output of the_method, with path_to_handle
set to ['1']

Now, if I try the following url or anythong longer:
http://localhost:7080/x/1/2
...I get:

Zope has encountered a problem publishing your object.
Cannot locate object at: http://localhost:7080/x/1/2

Traceback (innermost last):
  File E:\Zope\2271B4~1.2\lib\python\ZPublisher\Publish.py, line 222, in
publish_module
  File E:\Zope\2271B4~1.2\lib\python\ZPublisher\Publish.py, line 187, in
publish
  File E:\Zope\2271B4~1.2\lib\python\Zope\__init__.py, line 221, in
zpublisher_exception_hook
    (Object: the_method)
  File E:\Zope\2271B4~1.2\lib\python\ZPublisher\Publish.py, line 162, in
publish
  File E:\Zope\2271B4~1.2\lib\python\ZPublisher\BaseRequest.py, line
367, in traverse
  File E:\Zope\2271B4~1.2\lib\python\ZPublisher\HTTPResponse.py, line
539, in debugError
NotFound: (see above)

Can anyone (Evan?) suggest what's going on here and what I need to do to
fix it?

cheers,

Chris