[Zope-CMF] Re: CMF and Five views: hooking up "POST"
Tres Seaver
tseaver at palladion.com
Mon Oct 17 09:20:39 EDT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Lennart Regebro wrote:
> On 10/17/05, yuppie <y.2005- at wcm-solutions.de> wrote:
>
>>I know that pattern, but I don't like it. [...]
>>The code on the goldegg-folder_contents branch processes the input in
>>the __call__ method of the view class. The template is only invoked if
>>needed. It's much cleaner to use the template just for displaying
>>results, not for triggering controllers.
>
>
> That's purely a matter of taste. From a principal standpoint I don't
> think there is any difference, really.
I think we might be able to come up with a heuristic for choosing
between the two patterns (this might be a mini pattern language, if
refined):
- For "simple" forms, which redisplay themselves even after a
successful POST, and which do not redirect, prefer a template-driven
version, and make the form self-posting; in ZCML, use <browser:page>
with the 'template' attribute). The classic 'document_edit' form
fits this bill, I think.
- If you have to add logic to the template to cope with possible
redirects, then publish a method of the view, and have the view
redirect or return a template; in ZCML, use <browser:page> with
the 'attribute' variant. "Add" forms fit this pattern, as well
as the folder_contents stuff that Yuppie has done.
- For a set of inter-related pages sharing common view logic,
you may end up mixing and matching -- the ':method' bit on submit
button names is a way to get "off" the original template when
needed. ZCML for this case may either be a mixture of the
'template' and 'attribute' variants of <browser:page>, or else
<brower:view> with several <page> subdirectives.
How does that sound?
Tres.
- --
===================================================================
Tres Seaver +1 202-558-7113 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDU6Un+gerLs4ltQ4RAt7lAJsGoqwDOJ3JlzEsjGy5U2+wT36dvwCZAUde
BsjX68zwDWcatkVxWaF7ZoA=
=3aqS
-----END PGP SIGNATURE-----
More information about the Zope-CMF
mailing list