[Checkins] SVN: grok/trunk/src/grok/ renamed grok.resources to grok.templatedir in preparation for static resources.

Wolfgang Schnerring wosc at wosc.de
Tue Oct 17 09:59:47 EDT 2006


Log message for revision 70747:
  renamed grok.resources to grok.templatedir in preparation for static resources.

Changed:
  U   grok/trunk/src/grok/__init__.py
  U   grok/trunk/src/grok/_grok.py
  A   grok/trunk/src/grok/tests/view/dirandinlinetemplate/
  A   grok/trunk/src/grok/tests/view/dirandinlinetemplate.py
  A   grok/trunk/src/grok/tests/view/dirtemplate/
  A   grok/trunk/src/grok/tests/view/dirtemplate.py
  A   grok/trunk/src/grok/tests/view/dirtemplateandrender/
  A   grok/trunk/src/grok/tests/view/dirtemplateandrender.py
  D   grok/trunk/src/grok/tests/view/resourceandinlinetemplate/
  D   grok/trunk/src/grok/tests/view/resourceandinlinetemplate.py
  D   grok/trunk/src/grok/tests/view/resourcedirectory.py
  D   grok/trunk/src/grok/tests/view/resourcedirectoryname/
  D   grok/trunk/src/grok/tests/view/resourcetemplate/
  D   grok/trunk/src/grok/tests/view/resourcetemplate.py
  D   grok/trunk/src/grok/tests/view/resourcetemplateandrender/
  D   grok/trunk/src/grok/tests/view/resourcetemplateandrender.py
  A   grok/trunk/src/grok/tests/view/templatedirectory.py
  A   grok/trunk/src/grok/tests/view/templatedirectoryname/

-=-
Modified: grok/trunk/src/grok/__init__.py
===================================================================
--- grok/trunk/src/grok/__init__.py	2006-10-17 13:37:23 UTC (rev 70746)
+++ grok/trunk/src/grok/__init__.py	2006-10-17 13:59:47 UTC (rev 70747)
@@ -29,6 +29,6 @@
 from zope.event import notify
 
 from grok._grok import (Model, Adapter, MultiAdapter, View, PageTemplate,
-                   grok, context, name, template, resources, )
+                   grok, context, name, template, templatedir, )
 from grok._grok import SubscribeDecorator as subscribe
 from grok.error import GrokError, GrokImportError

Modified: grok/trunk/src/grok/_grok.py
===================================================================
--- grok/trunk/src/grok/_grok.py	2006-10-17 13:37:23 UTC (rev 70746)
+++ grok/trunk/src/grok/_grok.py	2006-10-17 13:59:47 UTC (rev 70747)
@@ -140,26 +140,26 @@
 
 def find_filesystem_templates(dotted_name, module, templates):
     module_name = dotted_name.split('.')[-1]
-    directory_name = directive_annotation(module, 'grok.resources', module_name)
+    directory_name = directive_annotation(module, 'grok.templatedir', module_name)
     if resource_exists(dotted_name, directory_name):
-        resources = resource_listdir(dotted_name, directory_name)
-        for resource in resources:
-            if not resource.endswith(".pt"):
+        template_files = resource_listdir(dotted_name, directory_name)
+        for template_file in template_files:
+            if not template_file.endswith(".pt"):
                 continue
-            template_name = resource[:-3]
-            resource_path = os.path.join(directory_name, resource)
+            template_name = template_file[:-3]
+            template_path = os.path.join(directory_name, template_file)
 
-            contents = resource_string(dotted_name, resource_path)
+            contents = resource_string(dotted_name, template_path)
             template = PageTemplate(contents)
             template.__grok_name__ = template_name
             # XXX is this zip-safe?
             template.__grok_location__ = os.path.join(
-                os.path.dirname(module.__file__), resource_path)
+                os.path.dirname(module.__file__), template_path)
 
             inline_template = templates.get(template_name)
             if inline_template:
                 raise GrokError("Conflicting templates found for name '%s' "
-                                "in module %r, both inline and in resource "
+                                "in module %r, both inline and in template "
                                 "directory '%s'."
                                 % (template_name, module, directory_name),
                                 inline_template)
@@ -315,7 +315,7 @@
 template = TextDirective('grok.template', ClassDirectiveContext())
 context = InterfaceOrClassDirective('grok.context',
                                     ClassOrModuleDirectiveContext())
-resources = TextDirective('grok.resources', ModuleDirectiveContext())
+templatedir = TextDirective('grok.templatedir', ModuleDirectiveContext())
 
 # decorators
 class SubscribeDecorator:

Copied: grok/trunk/src/grok/tests/view/dirandinlinetemplate (from rev 70732, grok/trunk/src/grok/tests/view/resourceandinlinetemplate)

Copied: grok/trunk/src/grok/tests/view/dirandinlinetemplate.py (from rev 70732, grok/trunk/src/grok/tests/view/resourceandinlinetemplate.py)
===================================================================
--- grok/trunk/src/grok/tests/view/resourceandinlinetemplate.py	2006-10-16 22:08:52 UTC (rev 70732)
+++ grok/trunk/src/grok/tests/view/dirandinlinetemplate.py	2006-10-17 13:59:47 UTC (rev 70747)
@@ -0,0 +1,21 @@
+"""
+If multiple templates can be found, one in the module and one in the
+template directory, there is an error:
+
+  >>> grok.grok(__name__)
+  Traceback (most recent call last):
+    ...
+  GrokError: Conflicting templates found for name 'cavepainting' in module
+  <module 'grok.tests.view.dirandinlinetemplate' from '...'>,
+  both inline and in template directory 'dirandinlinetemplate'.
+
+"""
+import grok
+
+class Mammoth(grok.Model):
+    pass
+
+class CavePainting(grok.View):
+    pass
+
+cavepainting = grok.PageTemplate("nothing")

Copied: grok/trunk/src/grok/tests/view/dirtemplate (from rev 70732, grok/trunk/src/grok/tests/view/resourcetemplate)

Copied: grok/trunk/src/grok/tests/view/dirtemplate.py (from rev 70732, grok/trunk/src/grok/tests/view/resourcetemplate.py)

Copied: grok/trunk/src/grok/tests/view/dirtemplateandrender (from rev 70732, grok/trunk/src/grok/tests/view/resourcetemplateandrender)

Copied: grok/trunk/src/grok/tests/view/dirtemplateandrender.py (from rev 70732, grok/trunk/src/grok/tests/view/resourcetemplateandrender.py)
===================================================================
--- grok/trunk/src/grok/tests/view/resourcetemplateandrender.py	2006-10-16 22:08:52 UTC (rev 70732)
+++ grok/trunk/src/grok/tests/view/dirtemplateandrender.py	2006-10-17 13:59:47 UTC (rev 70747)
@@ -0,0 +1,20 @@
+"""
+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:
+
+  >>> grok.grok(__name__)
+  Traceback (most recent call last):
+    ...
+  GrokError: Multiple possible ways to render view
+  <class 'grok.tests.view.dirtemplateandrender.CavePainting'>.
+  It has both a 'render' method as well as an associated template.
+
+"""
+import grok
+
+class Mammoth(grok.Model):
+    pass
+
+class CavePainting(grok.View):
+    def render(self):
+        pass

Deleted: grok/trunk/src/grok/tests/view/resourceandinlinetemplate.py
===================================================================
--- grok/trunk/src/grok/tests/view/resourceandinlinetemplate.py	2006-10-17 13:37:23 UTC (rev 70746)
+++ grok/trunk/src/grok/tests/view/resourceandinlinetemplate.py	2006-10-17 13:59:47 UTC (rev 70747)
@@ -1,21 +0,0 @@
-"""
-If multiple templates can be found, one in the module and one in the
-resource directory, there is an error:
-
-  >>> grok.grok(__name__)
-  Traceback (most recent call last):
-    ...
-  GrokError: Conflicting templates found for name 'cavepainting' in module
-  <module 'grok.tests.view.resourceandinlinetemplate' from '...'>,
-  both inline and in resource directory 'resourceandinlinetemplate'.
-
-"""
-import grok
-
-class Mammoth(grok.Model):
-    pass
-
-class CavePainting(grok.View):
-    pass
-
-cavepainting = grok.PageTemplate("nothing")

Deleted: grok/trunk/src/grok/tests/view/resourcedirectory.py
===================================================================
--- grok/trunk/src/grok/tests/view/resourcedirectory.py	2006-10-17 13:37:23 UTC (rev 70746)
+++ grok/trunk/src/grok/tests/view/resourcedirectory.py	2006-10-17 13:59:47 UTC (rev 70747)
@@ -1,24 +0,0 @@
-"""
-You can explicitly specify the resource directory using grok.resources on module level:
-
-  >>> grok.grok(__name__)
-
-  >>> manfred = Mammoth()
-  >>> from zope.publisher.browser import TestRequest
-  >>> request = TestRequest()
-  >>> from zope import component
-  >>> view = component.getMultiAdapter((manfred, request), name='food')
-  >>> print view()
-  <html>
-  <body>
-  ME GROK EAT MAMMOTH!
-  </body>
-  </html>
-
-"""
-import grok
-
-grok.resources('resourcedirectoryname')
-
-class Mammoth(grok.Model):
-    pass

Deleted: grok/trunk/src/grok/tests/view/resourcetemplate.py
===================================================================
--- grok/trunk/src/grok/tests/view/resourcetemplate.py	2006-10-17 13:37:23 UTC (rev 70746)
+++ grok/trunk/src/grok/tests/view/resourcetemplate.py	2006-10-17 13:59:47 UTC (rev 70747)
@@ -1,33 +0,0 @@
-"""
-Templates can also be found in a directory with the same name as the module:
-
-  >>> grok.grok(__name__)
-  
-  >>> manfred = Mammoth()
-  >>> from zope.publisher.browser import TestRequest
-  >>> request = TestRequest()
-  >>> from zope import component
-  >>> view = component.getMultiAdapter((manfred, request), name='cavepainting')
-  >>> print view()
-  <html>
-  <body>
-  A cave painting.
-  </body>
-  </html>
-
-  >>> view = component.getMultiAdapter((manfred, request), name='food')
-  >>> print view()
-  <html>
-  <body>
-  ME GROK EAT MAMMOTH!
-  </body>
-  </html>
-
-"""
-import grok
-
-class Mammoth(grok.Model):
-    pass
-
-class CavePainting(grok.View):
-    pass

Deleted: grok/trunk/src/grok/tests/view/resourcetemplateandrender.py
===================================================================
--- grok/trunk/src/grok/tests/view/resourcetemplateandrender.py	2006-10-17 13:37:23 UTC (rev 70746)
+++ grok/trunk/src/grok/tests/view/resourcetemplateandrender.py	2006-10-17 13:59:47 UTC (rev 70747)
@@ -1,20 +0,0 @@
-"""
-A View may either have an associated template or a render-method. Here
-we check that this also works for templates in a resource-directory:
-
-  >>> grok.grok(__name__)
-  Traceback (most recent call last):
-    ...
-  GrokError: Multiple possible ways to render view
-  <class 'grok.tests.view.resourcetemplateandrender.CavePainting'>.
-  It has both a 'render' method as well as an associated template.
-
-"""
-import grok
-
-class Mammoth(grok.Model):
-    pass
-
-class CavePainting(grok.View):
-    def render(self):
-        pass

Copied: grok/trunk/src/grok/tests/view/templatedirectory.py (from rev 70732, grok/trunk/src/grok/tests/view/resourcedirectory.py)
===================================================================
--- grok/trunk/src/grok/tests/view/resourcedirectory.py	2006-10-16 22:08:52 UTC (rev 70732)
+++ grok/trunk/src/grok/tests/view/templatedirectory.py	2006-10-17 13:59:47 UTC (rev 70747)
@@ -0,0 +1,24 @@
+"""
+You can explicitly specify the template directory using grok.templatedir on module level:
+
+  >>> grok.grok(__name__)
+
+  >>> manfred = Mammoth()
+  >>> from zope.publisher.browser import TestRequest
+  >>> request = TestRequest()
+  >>> from zope import component
+  >>> view = component.getMultiAdapter((manfred, request), name='food')
+  >>> print view()
+  <html>
+  <body>
+  ME GROK EAT MAMMOTH!
+  </body>
+  </html>
+
+"""
+import grok
+
+grok.templatedir('templatedirectoryname')
+
+class Mammoth(grok.Model):
+    pass

Copied: grok/trunk/src/grok/tests/view/templatedirectoryname (from rev 70732, grok/trunk/src/grok/tests/view/resourcedirectoryname)



More information about the Checkins mailing list