nwingfield@che-llp.com wrote:
I am writing a custom product and would like to make use of the URL string to do some cool stuff. When writing a "Python Script" there is a handy variable called traverse_subpath that contains the elements of the URL to the right of the name of the script itself. However, Zope tends to raise an exception when I attempt this technique with other types of objects, namely the objects created with my custom product code.
For example:
http://www.mysite.com/myPythonScript/extra/stuff works fine, and I have access to a handy list like ['extra', 'stuff']
http://www.mysite.com/myCustomObject/extra/stuff raises an error, something like: Zope has encountered a problem publishing your object.
Is there a quick trick to incorporate traverse_subpath functionality into my product?
http://zope.org/Documentation/Books/ZDG/current/ObjectPublishing.stx under "traversal methods". By providing a __bobo_traverse__ you can stop traversal and provide a traversal sub-path to your object, just like Python scripts do. In fact, you can probably hunt that very code down for inspiration. Probably it goes very much like:: def __bobo_traverse__(self, request, key): if request.has_key('TraversalRequestNameStack'): self.traverse_subpath = request['TraversalRequestNameStack'] return self But keep in mind I just made that up. You'll probably have to do some work on the traversal path. I don't even recall if you get the whole thing, or only what you're involved in. Also: http://zope.org/Members/teyc/Wiki/BoboTraverse Once you do this, it would be a nice recipe on zopelabs.com. --jcc -- "Code generators follow the 80/20 rule. They solve most of the problems, but not all of the problems. There are always features and edge cases that will need hand-coding. Even if code generation could build 100 percent of the application, there will still be an endless supply of boring meetings about feature design." (http://www.devx.com/java/editorial/15511)