I usually handle this one of two ways: Pass the URL to come back to to the message/edit form. A convention is to used a "came_from" value such as: http://foo.com/myobject/edit?came_from=http://foo.com/myobject/baz Or sometimes simply using the HTTP_REFERER request variable works well enough though. So you could code it like so in ZTP: <input type="hidden" name="came_from" tal:attributes="value request/came_from | request/HTTP_REFERER | request/URL1" /> hth, Casey Luca Manini wrote:
Hi,
I'looking for a standard and flexible way (a Zope idiom) to do in Zope what's really easy to do in a normal GUI (no web) for a very common problem.
Suppose I have an index_html that lists some items. Each item has a link that allows to edit it. After edit I want to come back to the list [see 1].
The edit process will probably require:
1) a form (edit_html) to be displayed (to collect data), 2) a PythonScript (edit_script) to do the actual job, 3) a form (edit_ack) to be shown (to say OK or ERROR)
If everything goes fine I will (probably) like to go back to index_html, if there is an error I will like to (at least once) go back to edit_html.
Of course I don't want the edit_html to know (hard-coded) that its "backlink" is index_html (it will not always be the case).
I can accept edit_script and edit_ack to know who call them (it will be probably be edit_html), but also in edit_ack it would be nice to have a way to go back to the original caller (with a Cancel button).
When doing everything from a Python Product, things are somewhat easier because you are always in the context of the edited/added object and you can mantain some "editing state" and return the appropriate form; but how to do it just with DTML Methods and Python Scripts?
Any hint? TIA, Luca.
PS: Almost all the "small" Zope examples I've seen do not help a lot in this regard because quite often they use the FORM action and a single button (too simple for real cases), or they use a single kitchen-sink DTML with <dtml-if> and some trick to hold state (does not scale well).
[1] Note: that's the same like adding an Folder to a Folder, but:
1) after adding the folder, you're sent back to the "right" place because everything is done by manage_addFolder that is called in the context of the contaning Folder and has the "backlink" (self.manage_main) hard-coded in its python code.
So this is not a general "solution".
2) If everything goes fine you do not get any confirmation (ok you get the list and you see the new Folder),
3) If there is an error (ex: duplicated id) you are left with a Zope traceback with NO LINK to the original place.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )