[Checkins] SVN: grokcore.formlib/trunk/ Fix for https://bugs.launchpad.net/grok/1.0/+bug/236897
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Tue Jan 6 16:25:33 EST 2009
Log message for revision 94554:
Fix for https://bugs.launchpad.net/grok/1.0/+bug/236897
Changed:
U grokcore.formlib/trunk/CHANGES.txt
U grokcore.formlib/trunk/src/grokcore/formlib/components.py
U grokcore.formlib/trunk/src/grokcore/formlib/ftests/form/actions.py
-=-
Modified: grokcore.formlib/trunk/CHANGES.txt
===================================================================
--- grokcore.formlib/trunk/CHANGES.txt 2009-01-06 20:44:59 UTC (rev 94553)
+++ grokcore.formlib/trunk/CHANGES.txt 2009-01-06 21:25:32 UTC (rev 94554)
@@ -4,7 +4,8 @@
1.1 (unreleased)
----------------
-* ...
+* Have GrokForm define an empty actions attribute by default, in order
+ for "action-less" forms to work easily.
1.0 (2008-09-25)
----------------
Modified: grokcore.formlib/trunk/src/grokcore/formlib/components.py
===================================================================
--- grokcore.formlib/trunk/src/grokcore/formlib/components.py 2009-01-06 20:44:59 UTC (rev 94553)
+++ grokcore.formlib/trunk/src/grokcore/formlib/components.py 2009-01-06 21:25:32 UTC (rev 94554)
@@ -46,6 +46,8 @@
'renaming' zope.formlib's update() to update_form() and by
disallowing subclasses to have custom render() methods."""
+ actions = form.Actions()
+
def update(self):
"""Subclasses can override this method just like on regular
grok.Views. It will be called before any form processing
Modified: grokcore.formlib/trunk/src/grokcore/formlib/ftests/form/actions.py
===================================================================
--- grokcore.formlib/trunk/src/grokcore/formlib/ftests/form/actions.py 2009-01-06 20:44:59 UTC (rev 94553)
+++ grokcore.formlib/trunk/src/grokcore/formlib/ftests/form/actions.py 2009-01-06 21:25:32 UTC (rev 94554)
@@ -42,6 +42,14 @@
>>> browser.getControl("Meet").click()
>>> print browser.contents
Manfred the Second meets Ellie
+
+There used to be a bug (or rather an inconvenience) where when no actions were
+defined, the template used for rendering a Form component would fail expecting
+to find an actions attribute on the component. This is fixed now and thus the
+following view does not raise an AttributeError anymore::
+
+ >>> browser.open("http://localhost/manfred/greet")
+
"""
import grokcore.formlib as grok
from zope import schema
@@ -57,8 +65,8 @@
grok.testing.protect_get(grok.Public, 'name', 'size')
grok.testing.protect_set(grok.Public, 'name', 'size')
- name = FieldProperty(IMammoth['name'])
- size = FieldProperty(IMammoth['size'])
+ name = FieldProperty(IMammoth['name'])
+ size = FieldProperty(IMammoth['size'])
class Edit(grok.EditForm):
@grok.action("Apply")
@@ -81,3 +89,7 @@
@grok.action('Meet')
def meet(self, other):
return self.context.name + ' meets ' + other
+
+class Greet(grok.Form):
+ form_fields = grok.Fields(
+ other = schema.TextLine(title=u'Mammoth to say hi to'))
More information about the Checkins
mailing list