[Checkins] SVN: grok/trunk/src/grok/ do not allow both a
render-method and a template
Wolfgang Schnerring
wosc at wosc.de
Mon Oct 16 08:23:57 EDT 2006
Log message for revision 70685:
do not allow both a render-method and a template
Changed:
U grok/trunk/src/grok/_grok.py
A grok/trunk/src/grok/tests/view/eithertemplateorrender.py
-=-
Modified: grok/trunk/src/grok/_grok.py
===================================================================
--- grok/trunk/src/grok/_grok.py 2006-10-16 12:03:59 UTC (rev 70684)
+++ grok/trunk/src/grok/_grok.py 2006-10-16 12:23:57 UTC (rev 70685)
@@ -115,6 +115,11 @@
% (factory, template_name, factory_name))
if template:
+ if getattr(factory, 'render', None):
+ raise GrokError("Multiple possible ways to render view %r. "
+ "It has both a 'render' method as well as "
+ "an associated template." % factory)
+
templates.markAssociated(template_name)
factory.template = template
else:
Added: grok/trunk/src/grok/tests/view/eithertemplateorrender.py
===================================================================
--- grok/trunk/src/grok/tests/view/eithertemplateorrender.py 2006-10-16 12:03:59 UTC (rev 70684)
+++ grok/trunk/src/grok/tests/view/eithertemplateorrender.py 2006-10-16 12:23:57 UTC (rev 70685)
@@ -0,0 +1,20 @@
+"""
+Only one, either a template, or render() can be specified:
+
+ >>> grok.grok(__name__)
+ Traceback (most recent call last):
+ ...
+ GrokError: Multiple possible ways to render view
+ <class 'grok.tests.view.eithertemplateorrender.CavePainting'>.
+ It has both a 'render' method as well as an associated template.
+"""
+import grok
+
+class Mammoth(grok.Model):
+ pass
+
+class CavePainting(grok.View):
+ def render(self):
+ pass
+
+cavepainting = grok.PageTemplate("nothing")
More information about the Checkins
mailing list