[Checkins] SVN: plone.z3cform/trunk/ Fix for http://code.google.com/p/dexterity/issues/detail?id=98
Martin Aspeli
optilude at gmx.net
Mon Jun 7 06:20:00 EDT 2010
Log message for revision 113236:
Fix for http://code.google.com/p/dexterity/issues/detail?id=98
Changed:
U plone.z3cform/trunk/docs/HISTORY.txt
U plone.z3cform/trunk/plone/z3cform/fieldsets/README.txt
U plone.z3cform/trunk/plone/z3cform/fieldsets/utils.py
-=-
Modified: plone.z3cform/trunk/docs/HISTORY.txt
===================================================================
--- plone.z3cform/trunk/docs/HISTORY.txt 2010-06-07 09:38:43 UTC (rev 113235)
+++ plone.z3cform/trunk/docs/HISTORY.txt 2010-06-07 10:20:00 UTC (rev 113236)
@@ -4,6 +4,9 @@
0.6.1 - unreleased
------------------
+* Fix re-ordering of fields not in the default fieldset. Thanks to Thomas
+ Buchberger for the patch.
+ [optilude]
0.6.0 - 2010-04-20
------------------
Modified: plone.z3cform/trunk/plone/z3cform/fieldsets/README.txt
===================================================================
--- plone.z3cform/trunk/plone/z3cform/fieldsets/README.txt 2010-06-07 09:38:43 UTC (rev 113235)
+++ plone.z3cform/trunk/plone/z3cform/fieldsets/README.txt 2010-06-07 10:20:00 UTC (rev 113236)
@@ -68,6 +68,7 @@
... bar = schema.TextLine(title=u"Bar")
... baz = schema.TextLine(title=u"Baz")
... fub = schema.TextLine(title=u"Fub")
+ ... qux = schema.TextLine(title=u"Qux")
One plausible implementation is to use an annotation to store this data.
@@ -82,6 +83,7 @@
... bar = u""
... baz = u""
... fub = u""
+ ... qux = u""
>>> ExtraBehavior = factory(ExtraBehavior)
>>> provideAdapter(ExtraBehavior)
@@ -93,7 +95,7 @@
>>> class ExtraBehaviorExtender(extensible.FormExtender):
... adapts(Test, TestRequest, TestForm) # context, request, form
- ...
+ ...
... def __init__(self, context, request, form):
... self.context = context
... self.request = request
@@ -121,8 +123,14 @@
... self.remove('bar', prefix='extra')
... self.add(all_fields.select('bar', prefix='extra'), group='Second')
...
- ... # Move 'baz' after 'bar'. This means it also moves gropu.
+ ... # Move 'baz' after 'bar'. This means it also moves group.
... self.move('extra.baz', after='extra.bar')
+ ...
+ ... # Remove 'qux' and re-insert into 'Second' group,
+ ... # then move it before 'baz'
+ ... self.remove('qux', prefix='extra')
+ ... self.add(all_fields.select('qux', prefix='extra'), group='Second')
+ ... self.move('qux', before='baz', prefix='extra', relative_prefix='extra')
>>> provideAdapter(factory=ExtraBehaviorExtender, name=u"test.extender")
@@ -152,4 +160,4 @@
This should have the group fields provided by the adapter as well.
>>> form.groups[0].fields.keys()
- ['extra.bar', 'extra.baz']
+ ['extra.bar', 'extra.qux', 'extra.baz']
Modified: plone.z3cform/trunk/plone/z3cform/fieldsets/utils.py
===================================================================
--- plone.z3cform/trunk/plone/z3cform/fieldsets/utils.py 2010-06-07 09:38:43 UTC (rev 113235)
+++ plone.z3cform/trunk/plone/z3cform/fieldsets/utils.py 2010-06-07 10:20:00 UTC (rev 113236)
@@ -68,7 +68,13 @@
relative = expandPrefix(relative_prefix) + relative
if field_name not in form.fields:
- raise KeyError("Field %s not found" % field_name)
+ found = False
+ for group in getattr(form, 'groups', []):
+ if field_name in group.fields:
+ found = True
+ break
+ if not found:
+ raise KeyError("Field %s not found" % field_name)
if relative != '*' and relative not in form.fields:
found = False
More information about the checkins
mailing list