[Checkins] SVN: grokcore.view/trunk/ fix issue https://bugs.launchpad.net/grok/+bug/680528
Jan Wijbrand Kolman
cvs-admin at zope.org
Sun Apr 29 17:00:55 UTC 2012
Log message for revision 125419:
fix issue https://bugs.launchpad.net/grok/+bug/680528
Changed:
U grokcore.view/trunk/CHANGES.txt
U grokcore.view/trunk/src/grokcore/view/directive.py
U grokcore.view/trunk/src/grokcore/view/templatereg.py
U grokcore.view/trunk/src/grokcore/view/tests/view/templatedirectorynotfound.py
A grokcore.view/trunk/src/grokcore/view/tests/view/templatedirectorynotfound_fixture.py
-=-
Modified: grokcore.view/trunk/CHANGES.txt
===================================================================
--- grokcore.view/trunk/CHANGES.txt 2012-04-29 16:51:51 UTC (rev 125418)
+++ grokcore.view/trunk/CHANGES.txt 2012-04-29 17:00:52 UTC (rev 125419)
@@ -4,6 +4,9 @@
2.6.2 (unreleased)
------------------
+- Improve error message when a templatedir() directive points to a non-
+ existent directory. (fix launchpad issue 680528).
+
- Improve error message when a template is required for a component
but cannot be found (Fix Launchpad issue #225855, #242698).
Modified: grokcore.view/trunk/src/grokcore/view/directive.py
===================================================================
--- grokcore.view/trunk/src/grokcore/view/directive.py 2012-04-29 16:51:51 UTC (rev 125418)
+++ grokcore.view/trunk/src/grokcore/view/directive.py 2012-04-29 17:00:52 UTC (rev 125419)
@@ -29,8 +29,13 @@
raise GrokImportError(
"The '%s' directive can not contain path separator."
% directive.name)
+ # XXX kinda hackish...
+ dirname = os.path.dirname(directive.frame.f_locals['__file__'])
+ if not os.path.isdir(os.path.join(dirname, value)):
+ raise GrokImportError(
+ "The directory '%s' specified by the '%s' directive "
+ "cannot be found." % (value, directive.name))
-
# Define grok directives
Modified: grokcore.view/trunk/src/grokcore/view/templatereg.py
===================================================================
--- grokcore.view/trunk/src/grokcore/view/templatereg.py 2012-04-29 16:51:51 UTC (rev 125418)
+++ grokcore.view/trunk/src/grokcore/view/templatereg.py 2012-04-29 17:00:52 UTC (rev 125419)
@@ -204,6 +204,7 @@
template_dir_name = module_info.name + '_templates'
template_dir = module_info.getResourcePath(template_dir_name)
+
return template_dir
inline_template_registry = InlineTemplateRegistry()
Modified: grokcore.view/trunk/src/grokcore/view/tests/view/templatedirectorynotfound.py
===================================================================
--- grokcore.view/trunk/src/grokcore/view/tests/view/templatedirectorynotfound.py 2012-04-29 16:51:51 UTC (rev 125418)
+++ grokcore.view/trunk/src/grokcore/view/tests/view/templatedirectorynotfound.py 2012-04-29 17:00:52 UTC (rev 125419)
@@ -2,16 +2,13 @@
If the template directory you specify doesn't exist, you have a comprehensible
error:
- >>> grok.testing.grok(__name__)
+ >>> grok.testing.grok(
+ ... 'grokcore.view.tests.view.templatedirectorynotfound_fixture')
+ Traceback (most recent call last):
+ ...
+ GrokImportError: The directory 'idontexit' specified by the
+ 'templatedir' directive cannot be found.
"""
-import grokcore.view as grok
-
-grok.templatedir('idontexit')
-
-class Mammoth(grok.Context):
- pass
-
-class Food(grok.View):
- pass
+from grokcore import view as grok
Added: grokcore.view/trunk/src/grokcore/view/tests/view/templatedirectorynotfound_fixture.py
===================================================================
--- grokcore.view/trunk/src/grokcore/view/tests/view/templatedirectorynotfound_fixture.py (rev 0)
+++ grokcore.view/trunk/src/grokcore/view/tests/view/templatedirectorynotfound_fixture.py 2012-04-29 17:00:52 UTC (rev 125419)
@@ -0,0 +1,9 @@
+import grokcore.view as grok
+
+grok.templatedir('idontexit')
+
+class Mammoth(grok.Context):
+ pass
+
+class Food(grok.View):
+ pass
More information about the checkins
mailing list