Skip to content

Commit

Permalink
I'm sorry I need to revert some changes around updateWidgets. It just…
Browse files Browse the repository at this point in the history
… breaks too many high level tests. I'm sure it would break for others too.

The way to change the widgets prefix would be to override updateWidgets:
super(MyForm, self).updateWidgets('myprefix')
  • Loading branch information
Adam Groszer committed Nov 27, 2012
1 parent 17890c7 commit d88c986
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
18 changes: 7 additions & 11 deletions CHANGES.txt
Expand Up @@ -5,26 +5,22 @@ CHANGES
2.10.0 (unreleased)
-------------------

- Initialize widgets in ``update`` step. The ``updateWidgets`` method
is now responsible only for actually updating the widgets.
- The ``updateWidgets`` method has learned an argument
``prefix`` which allows setting the prefix of the field widgets
adapter.

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.

In addition, the ``updateWidgets`` method has learned an argument
``prefix`` which allows setting the prefix of the field widgets
adapter.

- Capitalize the messages 'no value' and 'select a value'. This change
has been applied also to the existing translations (where
applicable).
has been applied also to the existing translations (where applicable).

- `TextLinesConverter`: do not ignore newlines at the end of the inputted
- ``TextLinesConverter``: do not ignore newlines at the end of the inputted
string, thus do not eat blank items

- `TextLinesConverter`: toFieldValue, convert conversion exceptions to
`FormatterValidationError`, for cases like got a string instead of int
- ``TextLinesConverter``: toFieldValue, convert conversion exceptions to
``FormatterValidationError``, for cases like got a string instead of int

2.9.0 (2012-09-17)
------------------
Expand Down
4 changes: 2 additions & 2 deletions src/z3c/form/form.py
Expand Up @@ -123,6 +123,8 @@ def getContent(self):

def updateWidgets(self, prefix=None):
'''See interfaces.IForm'''
self.widgets = zope.component.getMultiAdapter(
(self, self.request, self.getContent()), interfaces.IWidgets)
if prefix is not None:
self.widgets.prefix = prefix
self.widgets.mode = self.mode
Expand All @@ -145,8 +147,6 @@ def extractData(self, setErrors=True):

def update(self):
'''See interfaces.IForm'''
self.widgets = zope.component.getMultiAdapter(
(self, self.request, self.getContent()), interfaces.IWidgets)
self.updateWidgets()

def render(self):
Expand Down
11 changes: 7 additions & 4 deletions src/z3c/form/group.py
Expand Up @@ -34,6 +34,8 @@ def __init__(self, context, request, parentForm):

def updateWidgets(self, prefix=None):
'''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)
Expand All @@ -44,7 +46,7 @@ def updateWidgets(self, prefix=None):

def update(self):
'''See interfaces.IForm'''
super(Group, self).update()
self.updateWidgets()
groups = []
for groupClass in self.groups:
# only instantiate the groupClass if it hasn't already
Expand Down Expand Up @@ -121,10 +123,9 @@ def applyChanges(self, data):

return changed

def updateWidgets(self, prefix=None):
def update(self):
'''See interfaces.IForm'''
super(GroupForm, self).updateWidgets(prefix=prefix)

self.updateWidgets()
groups = []
for groupClass in self.groups:
# only instantiate the groupClass if it hasn't already
Expand All @@ -136,3 +137,5 @@ def updateWidgets(self, prefix=None):
group.update()
groups.append(group)
self.groups = tuple(groups)
self.updateActions()
self.actions.execute()

0 comments on commit d88c986

Please sign in to comment.