[Checkins] SVN: z3c.form/trunk/ Initialize the field widget manager

Roger dev at projekt01.ch
Wed Sep 12 13:35:40 UTC 2012


Hi Marlthe

Your commit is incompatilbe with many different concepts.

For example:
If you have a form which injects an interface with directlyProvides
into the form. And this interface is responsible for adapt other
widgets, this will break because the new widgets don't get
adapted anymore during the updatWidgets call.

Even more bad, you can't call update for force to switch to new
widgets because this involves widget value extraction and this
could badly fail if your form switched to other widgets based
on action handling.

What is the reason that you moved the widget setup from
updateWidgets to form.update() call?

Probably we can find another concept for your usecase?

Regards
Roger Ineichen
_____________________________
END OF MESSAGE>

> Betreff: [Checkins] SVN: z3c.form/trunk/ Initialize the field widget
manager in the
> update-step, such that the widget update step is only responsible for
actually updating
> the widgets. The change is required to support the situation where you
want to
> change the co
> 
> Log message for revision 127831:
>   Initialize the field widget manager in the update-step, such that the
widget update
> step is only responsible for actually updating the widgets. The change is
required to
> support the situation where you want to change the common widget prefix
(which
> defaults to 'widgets.').
> 
> Changed:
>   U   z3c.form/trunk/CHANGES.txt
>   U   z3c.form/trunk/src/z3c/form/form.py
>   U   z3c.form/trunk/src/z3c/form/group.py
> 
> -=-
> Modified: z3c.form/trunk/CHANGES.txt
> ================================================================
> ===
> --- z3c.form/trunk/CHANGES.txt	2012-09-12 10:17:42 UTC (rev 127830)
> +++ z3c.form/trunk/CHANGES.txt	2012-09-12 11:52:05 UTC (rev 127831)
> @@ -2,6 +2,16 @@
>  CHANGES
>  =======
> 
> +In next release ...
> +
> +- Initialize widgets in ``update`` step. The ``updateWidgets`` method
> +  is now responsible only for actually updating the widgets.
> +
> +  This allows updating the common widgets prefix before the individual
> +  widgets are updated, useful for situations where neither a form, nor
> +  a widgets prefix is desired.
> +
> +
>  2.8.3 (unreleased)
>  ------------------
> 
> 
> Modified: z3c.form/trunk/src/z3c/form/form.py
> ================================================================
> ===
> --- z3c.form/trunk/src/z3c/form/form.py	2012-09-12 10:17:42 UTC (rev
127830)
> +++ z3c.form/trunk/src/z3c/form/form.py	2012-09-12 11:52:05 UTC (rev
127831)
> @@ -126,8 +126,6 @@
> 
>      def updateWidgets(self):
>          '''See interfaces.IForm'''
> -        self.widgets = zope.component.getMultiAdapter(
> -            (self, self.request, self.getContent()), interfaces.IWidgets)
>          self.widgets.mode = self.mode
>          self.widgets.ignoreContext = self.ignoreContext
>          self.widgets.ignoreRequest = self.ignoreRequest
> @@ -148,6 +146,8 @@
> 
>      def update(self):
>          '''See interfaces.IForm'''
> +        self.widgets = zope.component.getMultiAdapter(
> +            (self, self.request, self.getContent()), interfaces.IWidgets)
>          self.updateWidgets()
> 
>      def render(self):
> 
> Modified: z3c.form/trunk/src/z3c/form/group.py
> ================================================================
> ===
> --- z3c.form/trunk/src/z3c/form/group.py	2012-09-12 10:17:42 UTC (rev
127830)
> +++ z3c.form/trunk/src/z3c/form/group.py	2012-09-12 11:52:05 UTC (rev
> 127831)
> @@ -34,8 +34,6 @@
> 
>      def updateWidgets(self):
>          '''See interfaces.IForm'''
> -        self.widgets = zope.component.getMultiAdapter(
> -            (self, self.request, self.getContent()), interfaces.IWidgets)
>          for attrName in ('mode', 'ignoreRequest', 'ignoreContext',
>                           'ignoreReadonly'):
>              value = getattr(self.parentForm.widgets, attrName)
> @@ -44,7 +42,7 @@
> 
>      def update(self):
>          '''See interfaces.IForm'''
> -        self.updateWidgets()
> +        super(Group, self).update()
>          groups = []
>          for groupClass in self.groups:
>              # only instantiate the groupClass if it hasn't already
> @@ -121,9 +119,10 @@
> 
>          return changed
> 
> -    def update(self):
> +    def updateWidgets(self):
>          '''See interfaces.IForm'''
> -        self.updateWidgets()
> +        super(GroupForm, self).updateWidgets()
> +
>          groups = []
>          for groupClass in self.groups:
>              # only instantiate the groupClass if it hasn't already
> @@ -135,7 +134,3 @@
>              group.update()
>              groups.append(group)
>          self.groups = tuple(groups)
> -        self.updateActions()
> -        self.actions.execute()
> -        if self.refreshActions:
> -            self.updateActions()
> 
> _______________________________________________
> checkins mailing list
> checkins at zope.org
> https://mail.zope.org/mailman/listinfo/checkins




More information about the checkins mailing list