[Checkins] SVN: grok/trunk/src/grok/ views must either have an
associated template or a 'render' method.
Philipp von Weitershausen
philikon at philikon.de
Sun Oct 15 10:58:09 EDT 2006
Log message for revision 70656:
views must either have an associated template or a 'render' method.
Changed:
U grok/trunk/src/grok/_grok.py
A grok/trunk/src/grok/tests/view/notemplateorrender.py
-=-
Modified: grok/trunk/src/grok/_grok.py
===================================================================
--- grok/trunk/src/grok/_grok.py 2006-10-15 14:50:51 UTC (rev 70655)
+++ grok/trunk/src/grok/_grok.py 2006-10-15 14:58:08 UTC (rev 70656)
@@ -46,9 +46,6 @@
namespace['context'] = self.context
return template.pt_render(namespace)
- def render(self):
- raise NotImplementedError
-
class GrokTemplate(TrustedAppPT, PageTemplate):
expand = 0
@@ -102,6 +99,10 @@
% (template_name, factory))
factory.template = GrokTemplate()
factory.template.write(template)
+ else:
+ if not getattr(factory, 'render', None):
+ raise GrokError("View %r has no associated template or "
+ "'render' method." % factory)
component.provideAdapter(factory,
adapts=(view_context, IDefaultBrowserLayer),
Added: grok/trunk/src/grok/tests/view/notemplateorrender.py
===================================================================
--- grok/trunk/src/grok/tests/view/notemplateorrender.py 2006-10-15 14:50:51 UTC (rev 70655)
+++ grok/trunk/src/grok/tests/view/notemplateorrender.py 2006-10-15 14:58:08 UTC (rev 70656)
@@ -0,0 +1,18 @@
+"""
+Views either need an associated template or a ``render`` method:
+
+ >>> grok.grok(__name__)
+ Traceback (most recent call last):
+ ...
+ GrokError: View <class 'grok.tests.view.notemplateorrender.CavePainting'>
+ has no associated template or 'render' method.
+
+"""
+
+import grok
+
+class Mammoth(grok.Model):
+ pass
+
+class CavePainting(grok.View):
+ pass
Property changes on: grok/trunk/src/grok/tests/view/notemplateorrender.py
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Checkins
mailing list