[Checkins] SVN: grok/trunk/src/grok/ test that a module can not
contain both a 'static' resource directory and a module named
'static.py'
Wolfgang Schnerring
wosc at wosc.de
Wed Oct 18 07:33:26 EDT 2006
Log message for revision 70777:
test that a module can not contain both a 'static' resource directory and a module named 'static.py'
Changed:
U grok/trunk/src/grok/_grok.py
A grok/trunk/src/grok/tests/static/statichaspy.py
A grok/trunk/src/grok/tests/static/statichaspy_fixture/
A grok/trunk/src/grok/tests/static/statichaspy_fixture/__init__.py
A grok/trunk/src/grok/tests/static/statichaspy_fixture/static/
A grok/trunk/src/grok/tests/static/statichaspy_fixture/static.py
-=-
Modified: grok/trunk/src/grok/_grok.py
===================================================================
--- grok/trunk/src/grok/_grok.py 2006-10-18 11:29:12 UTC (rev 70776)
+++ grok/trunk/src/grok/_grok.py 2006-10-18 11:33:25 UTC (rev 70777)
@@ -128,9 +128,16 @@
resource_path = module_info.getResourcePath('static')
if os.path.isdir(resource_path):
- if scan.is_package(resource_path):
- raise GrokError("The 'static' resource directory must not "
- "be a python package.", module_info.getModule())
+ static_module = module_info.getSubModuleInfo('static')
+ if static_module is not None:
+ if static_module.isPackage():
+ raise GrokError("The 'static' resource directory must not "
+ "be a python package.", module_info.getModule())
+ else:
+ raise GrokError("A package can not contain both a 'static' "
+ "resource directory and a module named "
+ "'static.py'", module_info.getModule())
+
register_static_resources(module_info.dotted_name, resource_path)
for sub_module_info in module_info.getSubModuleInfos():
Added: grok/trunk/src/grok/tests/static/statichaspy.py
===================================================================
--- grok/trunk/src/grok/tests/static/statichaspy.py 2006-10-18 11:29:12 UTC (rev 70776)
+++ grok/trunk/src/grok/tests/static/statichaspy.py 2006-10-18 11:33:25 UTC (rev 70777)
@@ -0,0 +1,11 @@
+"""
+When a package contains a 'static' resource directory, it must not also contain
+a module called 'static.py':
+
+ >>> import grok
+ >>> grok.grok('grok.tests.static.statichaspy_fixture')
+ Traceback (most recent call last):
+ ...
+ GrokError: A package can not contain both a 'static' resource directory
+ and a module named 'static.py'
+"""
Added: grok/trunk/src/grok/tests/static/statichaspy_fixture/__init__.py
===================================================================
--- grok/trunk/src/grok/tests/static/statichaspy_fixture/__init__.py 2006-10-18 11:29:12 UTC (rev 70776)
+++ grok/trunk/src/grok/tests/static/statichaspy_fixture/__init__.py 2006-10-18 11:33:25 UTC (rev 70777)
@@ -0,0 +1 @@
+# this is a package
Added: grok/trunk/src/grok/tests/static/statichaspy_fixture/static.py
===================================================================
--- grok/trunk/src/grok/tests/static/statichaspy_fixture/static.py 2006-10-18 11:29:12 UTC (rev 70776)
+++ grok/trunk/src/grok/tests/static/statichaspy_fixture/static.py 2006-10-18 11:33:25 UTC (rev 70777)
@@ -0,0 +1,2 @@
+# This is an error: there can be no python module named 'static.py' when there
+# is a 'static' resource directory
More information about the Checkins
mailing list