[Checkins] SVN: grokcore.view/trunk/src/grokcore/view/meta.py Start
splitting a big chunk of form-related stuff out to a
form-specific grokker.
Philipp von Weitershausen
philikon at philikon.de
Tue Jul 22 16:35:17 EDT 2008
Log message for revision 88737:
Start splitting a big chunk of form-related stuff out to a form-specific grokker.
Unfortunately, ViewGrokker isn't form-free yet.
Changed:
U grokcore.view/trunk/src/grokcore/view/meta.py
-=-
Modified: grokcore.view/trunk/src/grokcore/view/meta.py
===================================================================
--- grokcore.view/trunk/src/grokcore/view/meta.py 2008-07-22 20:28:34 UTC (rev 88736)
+++ grokcore.view/trunk/src/grokcore/view/meta.py 2008-07-22 20:35:16 UTC (rev 88737)
@@ -46,22 +46,9 @@
# Need to store the module info object on the view class so that it
# can look up the 'static' resource directory.
factory.module_info = module_info
- return super(ViewGrokker, self).grok(name, factory, module_info,
- **kw)
+ return super(ViewGrokker, self).grok(name, factory, module_info, **kw)
def execute(self, factory, config, context, layer, name, **kw):
- if util.check_subclass(factory, components.GrokForm):
- # setup form_fields from context class if we've encountered a form
- if getattr(factory, 'form_fields', None) is None:
- factory.form_fields = formlib.get_auto_fields(context)
-
- if not getattr(factory.render, 'base_method', False):
- raise GrokError(
- "It is not allowed to specify a custom 'render' "
- "method for form %r. Forms either use the default "
- "template or a custom-supplied one." % factory,
- factory)
-
# find templates
templates = factory.module_info.getAnnotation('grok.templates', None)
if templates is not None:
@@ -118,6 +105,25 @@
return True
+class FormGroker(martian.ClassGrokker):
+ martian.component(components.GrokForm)
+ martian.directive(grokcore.component.context)
+
+ def execute(self, factory, config, context, **kw):
+ # Set up form_fields from context class if they haven't been
+ # configured manually already.
+ if getattr(factory, 'form_fields', None) is None:
+ factory.form_fields = formlib.get_auto_fields(context)
+
+ if not getattr(factory.render, 'base_method', False):
+ raise GrokError(
+ "It is not allowed to specify a custom 'render' "
+ "method for form %r. Forms either use the default "
+ "template or a custom-supplied one." % factory,
+ factory)
+ return True
+
+
class PermissionGrokker(martian.ClassGrokker):
martian.component(grokcore.view.Permission)
martian.priority(1500)
More information about the Checkins
mailing list