[Zope] Help: PATH_INFO==>object
Martijn Pieters
mj@digicool.com
Fri, 8 Sep 2000 15:05:29 +0200
On Fri, Sep 08, 2000 at 08:01:58PM +0800, Li Dongfeng wrote:
> Thanks for the correction. Now I see that
> PATH_INFO refers to the current page,
> not the calling page. I think the hidden input
> field solution is OK for me.
>
> What is the *Traversal interface*? Do you
> mean the PARENTS enviroment?
The interface defines methods that let you convert a URL path into an
object reference. It does the same thing as the ZPublisher does when
processing a URL request. The PARENTS list is constructed during such
traversal; it is a stack of references to objects that were 'traversed';
asked for a reference to an object given the name of the next URL
element.
The method you are looking for is restrictedTraverse:
restrictedTraverse(path[, default])
where path is a object path seperated by '/' (no http://hostname part!).
If the path starts with a '/' it is supposed to be an absolute URL from
the site root, otherwise it is a relative path. Parent directory
references ('../') are allowed. The method will check for the appropriate
access along the way. The optional 'default' will be returned if the
traversal fails.
You should be able to use restrictedTraverse from DTML in Zope 2.2.1. In
Zope 2.2.0 you will need an External Method to access it (this was a bug),
and the method isn't implemented in any earlier versions of Zope.
If you want to pass along a object reference as a hidden FORM variable,
the you should use getPhysicalPath, and use _.string.join to turn the
result of that into a useful string:
<dtml-var "_.string.join(getPhysicalPath(), '/')">
--
Martijn Pieters
| Software Engineer mailto:mj@digicool.com
| Digital Creations http://www.digicool.com/
| Creators of Zope http://www.zope.org/
| ZopeStudio: http://www.zope.org/Products/ZopeStudio
-----------------------------------------------------