[Grok-dev] Re: grok.View: Self-submitting forms, redirect, and
before()
Christian Theune
ct at gocept.com
Wed Jan 10 11:06:57 EST 2007
Sounds good to me.
Am Mittwoch, den 10.01.2007, 16:46 +0100 schrieb Philipp von
Weitershausen:
> Martijn Faassen wrote:
> > Philipp von Weitershausen wrote:
> > [snip]
> >> The redirect use case isn't properly addressed by before() currently.
> >> So I'm wondering whether we should have two separate methods for this
> >> (e.g. process() and prepare()) of which the process() method would
> >> allow to redirect somewhere, causing grok.View never to render the
> >> template. If that's overkill, then we should at least consider adding
> >> that possibility to before() (whose name would then be confusing, as
> >> it seems to already be to other people).
> >
> > I'm not tied to the name 'before' nor am I tied to the current semantics
> > of 'render'. Some suggestions:
> >
> > * could we employ the Zope 3 standard update/render technique in this? I
> > don't mean we *only* use this but perhaps we can use it as a foundation
> > to what we want.
> >
> > * try implementing process/prepare and see how the Wiki and your Herd
> > example (for instance) are affected.
>
> After some more discussion on IRC, the change Martijn and I agreed upon was:
>
> Index: src/grok/components.py
> ===================================================================
> --- src/grok/components.py (revision 71844)
> +++ src/grok/components.py (working copy)
> @@ -137,7 +137,11 @@
> interface.Interface,
> name=self.module_info.package_dotted_name)
>
> def __call__(self):
> - self.before()
> + self.update()
> + if self.request.response.getStatus() in (302, 303):
> + # Somewhere in update(), a redirect was triggered. Don't
> + # continue rendering the template or doing anything else.
> + return
>
> template = getattr(self, 'template', None)
> if not template:
> @@ -183,7 +187,7 @@
> def redirect(self, url):
> return self.request.response.redirect(url)
>
> - def before(self):
> + def update(self):
> pass
>
>
> Basically, we rename before() to update() and add the semantics that a
> redirect caused in update() will stop all further rendering.
>
>
--
gocept gmbh & co. kg - forsterstraße 29 - 06112 halle/saale - germany
www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20070110/7aef8bcb/attachment.bin
More information about the Grok-dev
mailing list