[Product-Developers] Re: z3c.form widget traversal and validation

Martin Aspeli optilude at gmail.com
Fri Mar 5 00:35:41 UTC 2010


Hi,

On 5 March 2010 08:17, David Glick <davidglick at groundwire.org> wrote:
> I have a z3c.form form that overrides its getContent method based on a
> property of the current authenticated member.  That is, the data being
> edited by the form depends on which user is logged in.

Okay.

> This form also has a NamedImage field (from plone.namedfile), which
> displays a preview of the current image by traversing to ++widget++logo
> on the form (logo is the name of the field).

Right.

> But this doesn't work in this case, because in order to traverse to a
> widget, the code that handles this traversal (in
> plone.z3cform.traversal) must call the form's update method, which in
> turn calls updateWidgets.  But update also relies on being able to get
> the form's data, so it calls getContent, which fails because there is no
> authenticated member yet, since authentication happens after traversal.

Ouch.

> Any ideas about how I can get out of this pickle?

Not really. You have to do update(), otherwise you don't have enough
information on the widget. In a lot of cases, the fields/widgets
aren't even fully konwn until update() is done.

Could you replace your getContent() return value with some kind of
proxy that lazily looks up the user?

Martin




More information about the Product-Developers mailing list