[Checkins] SVN: grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/te ongoing fixing of removed render support
Reinout van Rees
reinout at vanrees.org
Fri Jul 3 08:11:04 EDT 2009
Log message for revision 101435:
ongoing fixing of removed render support
Changed:
U grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/templatereg.py
U grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/template/pluggability.py
U grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/dirtemplateandrender.py
U grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/eithertemplateorrender.py
A grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/notemplate.py
D grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/notemplateorrender.py
-=-
Modified: grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/templatereg.py
===================================================================
--- grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/templatereg.py 2009-07-03 11:33:13 UTC (rev 101434)
+++ grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/templatereg.py 2009-07-03 12:11:04 UTC (rev 101435)
@@ -107,6 +107,7 @@
% (component_name, factory, template_name,
factory_name), factory)
template = self.get(template_name)
+ # TODO: strip render
if template is not None:
if has_render(factory):
# we do not accept render and template both for a view
@@ -122,8 +123,7 @@
else:
if has_no_render(factory):
# we do not accept a view without any way to render it
- raise GrokError("%s %r has no associated template or "
- "'render' method." %
+ raise GrokError("%s %r has no associated template." %
(component_name.title(), factory), factory)
class PageTemplateFileFactory(grokcore.component.GlobalUtility):
Modified: grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/template/pluggability.py
===================================================================
--- grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/template/pluggability.py 2009-07-03 11:33:13 UTC (rev 101434)
+++ grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/template/pluggability.py 2009-07-03 12:11:04 UTC (rev 101435)
@@ -2,12 +2,12 @@
Testing the plugging in of a template language
>>> grok.testing.grok(__name__)
-
+
>>> cave = Cave()
>>> from zope.publisher.browser import TestRequest
>>> request = TestRequest()
>>> from zope import component
-
+
# The inline template should work:
>>> view = component.getMultiAdapter((cave, request), name='sebaayeni')
>>> print view()
@@ -23,7 +23,7 @@
>>> print view()
<html><body>Kakadu is in Australia</body></html>
- # We should be able to extend the namespac in the view and
+ # We should be able to extend the namespac in the view and
>>> view = component.getMultiAdapter((cave, request), name='sierra')
>>> print view()
<html><body>Sierra de San Fransisco is in Mexico</body></html>
@@ -33,14 +33,15 @@
# Dummy template language:
class MyTemplate(object):
-
+
def __init__(self, text):
self._text = text
-
+
def render(self, **kw):
# Silliest template language ever:
return self._text % kw
+
class MyPageTemplate(grok.components.GrokTemplate):
def setFromString(self, string):
@@ -70,19 +71,19 @@
class Sebaayeni(grok.View):
pass
-
+
sebaayeni = MyPageTemplate('<html><body>Sebaayeni is in South Africa</body></html>')
class Lascaux(grok.View):
pass
-
+
lascaux = MyPageTemplate(filename='lascaux.html')
class Kakadu(grok.View):
pass
class Sierra(grok.View):
-
+
def namespace(self):
return {'cave': 'Sierra de San Fransisco',
'country': 'Mexico'}
Modified: grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/dirtemplateandrender.py
===================================================================
--- grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/dirtemplateandrender.py 2009-07-03 11:33:13 UTC (rev 101434)
+++ grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/dirtemplateandrender.py 2009-07-03 12:11:04 UTC (rev 101435)
@@ -1,15 +1,13 @@
"""
-A View may either have an associated template or a render-method. Here
-we check that this also works for templates in a template-directory:
+A View may only have an associated template. Not a render-method, for that
+you must use CodeView. Here we check that this also works for templates in a
+template-directory:
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
+ >>> grok.testing.grok(__name__)
+ Traceback (most recent call last):
...
- ConfigurationExecutionError: martian.error.GrokError: Multiple possible ways to render view
- <class 'grokcore.view.tests.view.dirtemplateandrender.CavePainting'>.
- It has both a 'render' method as well as an associated template.
- in:
-
+ GrokError: View Class '<class 'grokcore.view.tests.view.dirtemplateandrender.CavePainting'>' has a render method
+
"""
import grokcore.view as grok
Modified: grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/eithertemplateorrender.py
===================================================================
--- grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/eithertemplateorrender.py 2009-07-03 11:33:13 UTC (rev 101434)
+++ grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/eithertemplateorrender.py 2009-07-03 12:11:04 UTC (rev 101435)
@@ -1,13 +1,12 @@
"""
-Only one, either a template, or render() can be specified:
+Only a template may be specified, not a render() method. Use CodeView if you
+want a render method.
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
+ >>> grok.testing.grok(__name__)
+ Traceback (most recent call last):
...
- ConfigurationExecutionError: martian.error.GrokError: Multiple possible ways to render view
- <class 'grokcore.view.tests.view.eithertemplateorrender.CavePainting'>.
- It has both a 'render' method as well as an associated template.
- in:
+ GrokError: View Class '<class 'grokcore.view.tests.view.eithertemplateorrender.CavePainting'>' has a render method
+
"""
import grokcore.view as grok
Copied: grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/notemplate.py (from rev 101434, grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/notemplateorrender.py)
===================================================================
--- grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/notemplate.py (rev 0)
+++ grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/notemplate.py 2009-07-03 12:11:04 UTC (rev 101435)
@@ -0,0 +1,19 @@
+"""
+Views need an associated template.
+
+ >>> grok.testing.grok(__name__)
+ Traceback (most recent call last):
+ ...
+ ConfigurationExecutionError: <class 'martian.error.GrokError'>: View <class 'grokcore.view.tests.view.notemplate.CavePainting'> has no associated template.
+ in:
+ <BLANKLINE>
+
+"""
+
+import grokcore.view as grok
+
+class Mammoth(grok.Context):
+ pass
+
+class CavePainting(grok.View):
+ pass
Deleted: grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/notemplateorrender.py
===================================================================
--- grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/notemplateorrender.py 2009-07-03 11:33:13 UTC (rev 101434)
+++ grokcore.view/branches/reinout-christian-codeview/src/grokcore/view/tests/view/notemplateorrender.py 2009-07-03 12:11:04 UTC (rev 101435)
@@ -1,19 +0,0 @@
-"""
-Views either need an associated template or a ``render`` method:
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- ConfigurationExecutionError: martian.error.GrokError: View <class 'grokcore.view.tests.view.notemplateorrender.CavePainting'>
- has no associated template or 'render' method.
- in:
-
-"""
-
-import grokcore.view as grok
-
-class Mammoth(grok.Context):
- pass
-
-class CavePainting(grok.View):
- pass
More information about the Checkins
mailing list