[Zope] how to use the document object in a script

Alexis Roda arv@si.urv.es
Tue, 13 May 2003 18:59:58 +0200

Wim Bekker wrote:
> Wrestling with the ZopeBook (ScriptingZope.stx), I'm trying to call a script
> from a DTML document to return eq the title for the document (as learning
> curve).
> The document has:
> <form action="myScript" method="POST>
> <input type="submit">
> </form>
> The 'myScript' has:
> Return context.title
> The result is the title for the folder where the document is in. I'm
> expecting the title for the document itself.
> Context always seems to be the folder I'm working on. How do I get the
> object (document)?

myScript is not called from within your dtml-method. In your example
myScript is just a relative URL that triggers the execution of the
script when the user presses the submit button.

If I understand you (and zope) correctly, what you're trying to do is to
discover from where myScript is called, and this has nothing to do with
acquisition. You can find its URL looking at the REQUEST.HTTP_REFERER or
easier, create a hidden input in your form:

<form action="myScript" method="POST>
<input type="hidden" name="caller_title" value="&dtml-title;">
<input type="submit">

and add a caller_title parameter to myScript.

Maybe zope provides some nice way to determine the object which has
triggered the execution of myScript, I don't know ...
REQUEST.HTTP_REFERER and some traversal method can take you to the

                                 (@ @)
        Los pecados de los tres mundos desapareceran conmigo.
Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain)