[Zope-dev] form action in specific context

Martijn Faassen m.faassen@vet.uu.nl
Mon, 16 Aug 1999 14:03:09 +0200


Hi everybody,

I'm trying to find the best way to describe this problem. I'm dealing
with XML Document, but this could just occur if I have a folder
subfolders and some documents inside.

What I have is set of DTML methods that render the contents of an XML
Document to an XML page. It does this by going into the XML tree (which
you can see as a folder tree), and because through acquisition the right
DTML method to render a specific element (or type of folder) is known at
that element too, I simply call that method on that element to render.

I do stuff somewhat like this:

DTML Method render_foo:
<h2><dtml-var title></h2>
<dtml-with bar>
  <dtml-var render_bar>
</dtml-with>

DTML method render_bar:
<form action="form_response">
..
</form>
<p><dtml-var whateverproperty></p>

Basically, I just call different render_* DTML methods on subtrees,
which exist because of acquisition.

This all works well, and my HTML gets rendered. But as you see, I
included a form in render_bar. But then, on the rendered page, when I
submit the form, what is called by the form is *not* a DTML method on
the 'current' branch of the tree, but a DTML method at the folder where
the XML document resides. This is understandable, but not what I want; I
want to call a DTML method in the tree (that should be there because of
acquisition), because otherwise the DTML method will not have the right
context. In the example I'd like to call form_response in the context of
the object that is rendered by render_bar. So somehow I will need to do
something with this: <form action="????">. What should I put in the
action attribute? An alternative would be to use hyperlinks, and a
'href'. But how do I know what URL to call? The 'URL' Zope variable
isn't helpful, as it gives the URL of the root. I want the URL of the
current object that is rendered.

I'm afraid this all sounds terribly confusing. If so, please let me know
and ask questions, so I can clarify.

Regards,

Martijn