I am working on a small project based on ZPublisher (and I don't even want to think about how much work it would be without it!). One problem I have come across is how to provide some kind of "state information" or "pervasive user option". Almost all pages on my site have content that can be presented in various formats; essentially this is a user option. But it would be tedious for the users to specify this option over and over again. Ideally, they would make their choice once (on the starting page) and then forget about it. But somehow the information has to be passed on to the rest of my site. One solution would be cookies, but I'd like to avoid them for two reasons: many users disable cookies in their browsers, and I don't know how to use cookies with Zope. 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 Hinsen | E-Mail: hinsen@cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais -------------------------------------------------------------------------------
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
Mitch Chapman wrote:
templateStr = """... <FORM METHOD="POST" ...> <INPUT TYPE="HIDDEN" NAME="userOption" VALUE="<!--#var user_option-->"> ... """
Looks like what I need. I didn't know about hidden input fields; that doesn't seem to make much sense in normal circumstances. Thanks! BTW, isn't it scary that nowadays you can get replies from a mailing list faster than compiling a mid-size program took a few years ago? ;-) -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen@cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais -------------------------------------------------------------------------------
participants (2)
-
Konrad Hinsen -
Mitch Chapman