[Zope] - Passing around state information

Mitch Chapman mchapman@OEE.com
Tue, 19 Jan 1999 11:07:27 -0500


Konrad Hinsen wrote:
> Another solution would be to attach the option to each and every
> URL and always pass it around. But I can't see how to do that
> with forms; I'd have to persuade the form to return a value
> that it has received itself via its URL, but which is neither
> displayed nor entered by the user.
> 
> Any ideas?

Konrad,

I'll probably get this wrong, but:

----------------------------------------------------------------------
templateStr = """...
<FORM METHOD="POST" ...>
  <INPUT TYPE="HIDDEN" NAME="userOption"
   VALUE="<!--#var user_option-->">
...
"""

class PublishedThingy:
    some_form = DocumentTemplate.HTML(templateStr)

    def gimme_form(self, user_option):
        """Generate some form, with user_option (from the URL)
embedded."""
        return some_form(self, user_option=user_option)
----------------------------------------------------------------------

gimme_form returns a form which can be POSTed, and which contains 
the user_option as a hidden input.  If the user visits 
.../gimme_form using a GET, they supply the user_option as a URL 
parameter.  For a POST, it could be supplied as a form input or 
as a URL parameter.

Is that what you wanted to do?

-- 
Mitch Chapman			  |	4105 Executive Drive
Ohio Electronic Engravers, Inc.	  |	Beavercreek, OH  45430
mchapman@oee.com		  |	import StandardDisclaimer