[Checkins] SVN: five.grok/trunk/src/five/grok/ More tests.
Lennart Regebro
regebro at gmail.com
Thu Jul 17 09:18:20 EDT 2008
Log message for revision 88438:
More tests.
Changed:
U five.grok/trunk/src/five/grok/meta.py
A five.grok/trunk/src/five/grok/tests/view/__init__.pyc
A five.grok/trunk/src/five/grok/tests/view/ambiguouscontext.pyc
A five.grok/trunk/src/five/grok/tests/view/dirandinlinetemplate.pyc
A five.grok/trunk/src/five/grok/tests/view/dirtemplate.pyc
A five.grok/trunk/src/five/grok/tests/view/dirtemplateandrender.pyc
A five.grok/trunk/src/five/grok/tests/view/dirtemplatesonly.pyc
A five.grok/trunk/src/five/grok/tests/view/eithertemplateorrender.py
A five.grok/trunk/src/five/grok/tests/view/eithertemplateorrender.pyc
A five.grok/trunk/src/five/grok/tests/view/explicitimplicittemplate.py
A five.grok/trunk/src/five/grok/tests/view/explicitimplicittemplate.pyc
A five.grok/trunk/src/five/grok/tests/view/inline.pyc
A five.grok/trunk/src/five/grok/tests/view/inline_unassociated.py
A five.grok/trunk/src/five/grok/tests/view/inline_unassociated.pyc
A five.grok/trunk/src/five/grok/tests/view/inlinebogus.py
A five.grok/trunk/src/five/grok/tests/view/inlinebogus.pyc
A five.grok/trunk/src/five/grok/tests/view/missingcontext.py
A five.grok/trunk/src/five/grok/tests/view/missingcontext.pyc
A five.grok/trunk/src/five/grok/tests/view/view.pyc
-=-
Modified: five.grok/trunk/src/five/grok/meta.py
===================================================================
--- five.grok/trunk/src/five/grok/meta.py 2008-07-17 13:04:36 UTC (rev 88437)
+++ five.grok/trunk/src/five/grok/meta.py 2008-07-17 13:18:19 UTC (rev 88438)
@@ -132,4 +132,19 @@
callable=instance._annotateGrokInfo,
args=(name, module_info.dotted_name)
)
- return True
\ No newline at end of file
+ return True
+
+class UnassociatedTemplatesGrokker(martian.GlobalGrokker):
+ martian.priority(-1001)
+
+ def grok(self, name, module, module_info, config, **kw):
+ templates = module_info.getAnnotation('grok.templates', None)
+ if templates is None:
+ return False
+
+ config.action(
+ discriminator=None,
+ callable=templates.checkUnassociated,
+ args=(module_info,)
+ )
+ return True
Added: five.grok/trunk/src/five/grok/tests/view/__init__.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/__init__.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: five.grok/trunk/src/five/grok/tests/view/ambiguouscontext.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/ambiguouscontext.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: five.grok/trunk/src/five/grok/tests/view/dirandinlinetemplate.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/dirandinlinetemplate.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: five.grok/trunk/src/five/grok/tests/view/dirtemplate.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/dirtemplate.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: five.grok/trunk/src/five/grok/tests/view/dirtemplateandrender.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/dirtemplateandrender.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: five.grok/trunk/src/five/grok/tests/view/dirtemplatesonly.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/dirtemplatesonly.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: five.grok/trunk/src/five/grok/tests/view/eithertemplateorrender.py
===================================================================
--- five.grok/trunk/src/five/grok/tests/view/eithertemplateorrender.py (rev 0)
+++ five.grok/trunk/src/five/grok/tests/view/eithertemplateorrender.py 2008-07-17 13:18:19 UTC (rev 88438)
@@ -0,0 +1,21 @@
+"""
+Only one, either a template, or render() can be specified:
+
+ >>> grok.testing.grok(__name__)
+ Traceback (most recent call last):
+ ...
+ ConfigurationExecutionError: martian.error.GrokError: Multiple possible ways to render view
+ <class 'five.grok.tests.view.eithertemplateorrender.CavePainting'>.
+ It has both a 'render' method as well as an associated template.
+ in:
+"""
+from five import grok
+
+class Mammoth(grok.Model):
+ pass
+
+class CavePainting(grok.View):
+ def render(self):
+ pass
+
+cavepainting = grok.PageTemplate("nothing")
Property changes on: five.grok/trunk/src/five/grok/tests/view/eithertemplateorrender.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: five.grok/trunk/src/five/grok/tests/view/eithertemplateorrender.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/eithertemplateorrender.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: five.grok/trunk/src/five/grok/tests/view/explicitimplicittemplate.py
===================================================================
--- five.grok/trunk/src/five/grok/tests/view/explicitimplicittemplate.py (rev 0)
+++ five.grok/trunk/src/five/grok/tests/view/explicitimplicittemplate.py 2008-07-17 13:18:19 UTC (rev 88438)
@@ -0,0 +1,25 @@
+"""
+It is too confusing to have a template that would be implicitly
+associated with a view while that view already refers to another
+template using grok.template. Therefore there is an error:
+
+ >>> grok.testing.grok(__name__)
+ Traceback (most recent call last):
+ ...
+ ConfigurationExecutionError: martian.error.GrokError: Multiple possible templates for view
+ <class 'five.grok.tests.view.explicitimplicittemplate.Painting'>.
+ It uses grok.template('cavepainting'), but there is also a template
+ called 'painting'.
+ in:
+
+"""
+from five import grok
+
+class Mammoth(grok.Model):
+ pass
+
+class Painting(grok.View):
+ grok.template('cavepainting')
+
+cavepainting = grok.PageTemplate("GROK CAVEPAINT MAMMOTH!")
+painting = grok.PageTemplate("GROK PAINT MAMMOTH!")
Property changes on: five.grok/trunk/src/five/grok/tests/view/explicitimplicittemplate.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: five.grok/trunk/src/five/grok/tests/view/explicitimplicittemplate.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/explicitimplicittemplate.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: five.grok/trunk/src/five/grok/tests/view/inline.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/inline.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: five.grok/trunk/src/five/grok/tests/view/inline_unassociated.py
===================================================================
--- five.grok/trunk/src/five/grok/tests/view/inline_unassociated.py (rev 0)
+++ five.grok/trunk/src/five/grok/tests/view/inline_unassociated.py 2008-07-17 13:18:19 UTC (rev 88438)
@@ -0,0 +1,26 @@
+"""
+Inline templates that are not associated with a view class will
+provoke an error:
+
+ >>> from five.grok.testing import warn
+ >>> import warnings
+ >>> saved_warn = warnings.warn
+ >>> warnings.warn = warn
+
+ >>> grok.testing.grok(__name__)
+ From five.grok.testing's warn():
+ ...UserWarning: Found the following unassociated template(s) when grokking
+ 'five.grok.tests.view.inline_unassociated': club. Define view classes inheriting
+ from grok.View to enable the template(s)...
+
+ >>> warnings.warn = saved_warn
+
+"""
+from five import grok
+
+class Mammoth(grok.Model):
+ pass
+
+club = grok.PageTemplate("""\
+<html><body><h1>GROK CLUB MAMMOTH!</h1></body></html>
+""")
Property changes on: five.grok/trunk/src/five/grok/tests/view/inline_unassociated.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: five.grok/trunk/src/five/grok/tests/view/inline_unassociated.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/inline_unassociated.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: five.grok/trunk/src/five/grok/tests/view/inlinebogus.py
===================================================================
--- five.grok/trunk/src/five/grok/tests/view/inlinebogus.py (rev 0)
+++ five.grok/trunk/src/five/grok/tests/view/inlinebogus.py 2008-07-17 13:18:19 UTC (rev 88438)
@@ -0,0 +1,16 @@
+# -*- coding: latin-1 -*-
+"""
+We do not accept bogus inline template such as ones that contain
+encoded strings:
+
+ >>> from five import grok
+ >>> grok.PageTemplate('''
+ ... <html>
+ ... <body><h1 tal:content="string:Mammoth Cave Painting"/>
+ ... <p>ööö</p>
+ ... </body>
+ ... </html>''')
+ Traceback (most recent call last):
+ ...
+ ValueError: Invalid page template. Page templates must be unicode or ASCII.
+"""
Property changes on: five.grok/trunk/src/five/grok/tests/view/inlinebogus.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: five.grok/trunk/src/five/grok/tests/view/inlinebogus.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/inlinebogus.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: five.grok/trunk/src/five/grok/tests/view/missingcontext.py
===================================================================
--- five.grok/trunk/src/five/grok/tests/view/missingcontext.py (rev 0)
+++ five.grok/trunk/src/five/grok/tests/view/missingcontext.py 2008-07-17 13:18:19 UTC (rev 88438)
@@ -0,0 +1,16 @@
+"""
+Views without a context cannot be grokked:
+
+ >>> grok.testing.grok(__name__)
+ Traceback (most recent call last):
+ ...
+ GrokError: No module-level context for
+ <class 'five.grok.tests.view.missingcontext.Club'>, please use the
+ 'context' directive.
+
+"""
+
+from five import grok
+
+class Club(grok.View):
+ pass
Property changes on: five.grok/trunk/src/five/grok/tests/view/missingcontext.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: five.grok/trunk/src/five/grok/tests/view/missingcontext.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/missingcontext.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: five.grok/trunk/src/five/grok/tests/view/view.pyc
===================================================================
(Binary files differ)
Property changes on: five.grok/trunk/src/five/grok/tests/view/view.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
More information about the Checkins
mailing list