Daniele,
This came up fairly recently, and I had some comments on it, but rather than
repost, I'll provide a link.
http://mail.mems-exchange.org/pipermail/quixote-users/2004-February/002553.h
tml
This doesn't exactly answer your question, but it addresses the fact that
there doesn't seem to be an ideal answer to providing initial values in
form2, and one way of working around that (two actually, considering the
link to Andrew's idea).
Jason
> -----Original Message-----
> From: quixote-users-bounces+jsibre=chironsys.com@mems-exchange.org
> [mailto:quixote-users-bounces+jsibre=chironsys.com@mems-exchange.org]On
> Behalf Of Daniele Varrazzo
> Sent: Tuesday, February 24, 2004 11:57 AM
> To: Quixote
> Subject: [Quixote-users] form2: troubles from a get
>
>
> I am trying to convert a rather complex application to use form2
> instead of form: I think their design can simplify development. I
> am starting from the example published in
> http://mail.mems-exchange.org/pipermail/quixote-users/2003-October
/001998.html.
My app expects a request like http://localhost/esp/xpr/edit?id=247. In
xpr.ptl, the edit method fetches the record 247 from the database and use
its data to populate the form. But then
if not form.is_submitted():
return render()
this render is never executed because
globals()['_publisher'].get_request().form == {'id': '247'}, so
form.is_submitted() == 1 :-/
I solved this by defining
def is_submitted(self):
"""() -> bool
Return true if a form was submitted.
"""
r = get_request()
return r.get_environ('REQUEST_METHOD') == 'POST' and bool(r.form)
in my form subclass, but this wouldn't help if the form were generated by
another form...
Am I wrong? Maybe the tipical usage for form2 is different from the "if not
form.is_submitted(): return render()" pattern shown in that example?
Another question: what is the best way to populate the form before rendering
it? I can read it with a dict protocol, but how should I write control
values?
Bye
--
Daniele Varrazzo varrazzo@unisi.it
Dipartimento di Biologia Molecolare
Universita' di Siena
Via del Capitano, 15 53100 Siena (Italy)
_______________________________________________
Quixote-users mailing list
Quixote-users@mems-exchange.org
http://mail.mems-exchange.org/mailman/listinfo/quixote-users