[Zope] Help: PATH_INFO==>object

Martijn Pieters mj@digicool.com
Fri, 8 Sep 2000 11:01:08 +0200


On Fri, Sep 08, 2000 at 11:32:39AM +0800, Li Dongfeng wrote:
> I am writing a service for other pages to
> use as form action. How can I reference
> the caller object in DTML/python?
> 
> I can only think of this: First use PARENTS[-1]
> to get to the root object of the site.
> Then split the PATH_INFO containing the caller's
> path, and go down from the root to every subfolder
> in PATH_INFO and then get to the caller object.
> But this is not very elegant.
> 
> Can anyone give better solution to this?

PATH_INFO only tells you something about the service object, not about the
calling page. If you use this as a FORM action target, it's the browser
that makes the call, not Zope.

You can, in many cases, determine the browser URL by looking at
HTTP_REFERER, but many people and companies use proxies and firewalls to
filter this out nowadays; it is considered sensitive information.

If this app is targeted at a intranet or other controlled environment, you
could dictate the presence of HTTP_REFERER, and rely on that, otherwise
you will have to add a reference as a hidden form field generated by the
calling object.

Once you have a URL of the calling object, you can use the Traversal
interface to turn that URL into an object reference.

-- 
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
-----------------------------------------------------