[Checkins] SVN: grok/branches/regebro-guido-templates/ Expanded the
Template interface to reflect the actual need.
Lennart Regebro
regebro at gmail.com
Fri Oct 5 08:32:45 EDT 2007
Log message for revision 80635:
Expanded the Template interface to reflect the actual need.
Added a grok.direct directive.
Changed:
U grok/branches/regebro-guido-templates/CHANGES.txt
U grok/branches/regebro-guido-templates/src/grok/__init__.py
U grok/branches/regebro-guido-templates/src/grok/directive.py
U grok/branches/regebro-guido-templates/src/grok/interfaces.py
U grok/branches/regebro-guido-templates/src/grok/meta.py
U grok/branches/regebro-guido-templates/src/grok/templatereg.py
-=-
Modified: grok/branches/regebro-guido-templates/CHANGES.txt
===================================================================
--- grok/branches/regebro-guido-templates/CHANGES.txt 2007-10-05 11:41:31 UTC (rev 80634)
+++ grok/branches/regebro-guido-templates/CHANGES.txt 2007-10-05 12:32:44 UTC (rev 80635)
@@ -7,6 +7,10 @@
Feature changes
---------------
+* There is now a grok.direct() directive that can be used on GlobalUtilities to
+ mark that the class provides the utility directly and need no instantiation.
+ (XXX no test written yet /regebro)
+
* Integrated skins and layers. grok.layer, grok.IGrokLayer, grok.Skin
* Removed grok.define_permission in favor of the grok.Permission
Modified: grok/branches/regebro-guido-templates/src/grok/__init__.py
===================================================================
--- grok/branches/regebro-guido-templates/src/grok/__init__.py 2007-10-05 11:41:31 UTC (rev 80634)
+++ grok/branches/regebro-guido-templates/src/grok/__init__.py 2007-10-05 12:32:44 UTC (rev 80635)
@@ -39,7 +39,7 @@
from grok.components import Skin, IGrokLayer
from grok.directive import (context, name, title, template, templatedir,
provides, baseclass, global_utility, local_utility,
- permissions, require, site, layer)
+ permissions, require, site, layer, direct)
from grok._grok import do_grok as grok # Avoid name clash within _grok
from grok._grok import grok_component
from grok._grok import SubscribeDecorator as subscribe
Modified: grok/branches/regebro-guido-templates/src/grok/directive.py
===================================================================
--- grok/branches/regebro-guido-templates/src/grok/directive.py 2007-10-05 11:41:31 UTC (rev 80634)
+++ grok/branches/regebro-guido-templates/src/grok/directive.py 2007-10-05 12:32:44 UTC (rev 80635)
@@ -41,8 +41,10 @@
class GlobalUtilityInfo(object):
- def __init__(self, factory, provides=None, name=u'', direct=False):
+ def __init__(self, factory, provides=None, name=u'', direct=None):
self.factory = factory
+ if direct is None:
+ direct = util.class_annotation(factory, 'grok.direct', False)
self.direct = direct
if provides is None:
@@ -122,3 +124,4 @@
'grok.permissions', ClassDirectiveContext())
layer = InterfaceOrClassDirective('grok.layer',
ClassOrModuleDirectiveContext())
+direct = MarkerDirective('grok.direct', ClassDirectiveContext())
\ No newline at end of file
Modified: grok/branches/regebro-guido-templates/src/grok/interfaces.py
===================================================================
--- grok/branches/regebro-guido-templates/src/grok/interfaces.py 2007-10-05 11:41:31 UTC (rev 80634)
+++ grok/branches/regebro-guido-templates/src/grok/interfaces.py 2007-10-05 12:32:44 UTC (rev 80635)
@@ -430,10 +430,11 @@
index for interface or class context.
"""
-class ITemplateFactory(interface.Interface):
- """Utility that generated templates. One per template type/extension"""
+class ITemplateFileFactory(interface.Interface):
+ """Utility that generates templates from files in template directories.
+ """
- def __call__(self, filename, _prefix=None):
+ def __call__(filename, _prefix=None):
"""Creates an ITemplateFile
_prefix is the directory the file is located in
@@ -443,6 +444,15 @@
"""Template objects created from files
"""
- def __call__(self, args, request):
+ def __call__(args, request):
"""Renders the template. Args is a tuple of arguments."""
+
+ def _factory_init(factory):
+ """Template language specific initializations on the view."""
+
+ def getDefaultVariables():
+ """Returns a dictionary of template language specific variables."""
+
+ def render_template(view):
+ """Renders the template"""
\ No newline at end of file
Modified: grok/branches/regebro-guido-templates/src/grok/meta.py
===================================================================
--- grok/branches/regebro-guido-templates/src/grok/meta.py 2007-10-05 11:41:31 UTC (rev 80634)
+++ grok/branches/regebro-guido-templates/src/grok/meta.py 2007-10-05 12:32:44 UTC (rev 80635)
@@ -85,7 +85,10 @@
if provides is None:
util.check_implements_one(factory)
name = util.class_annotation(factory, 'grok.name', '')
- component.provideUtility(factory(), provides=provides, name=name)
+ direct = util.class_annotation(factory, 'grok.direct', False)
+ if not direct:
+ factory = factory()
+ component.provideUtility(factory, provides=provides, name=name)
return True
Modified: grok/branches/regebro-guido-templates/src/grok/templatereg.py
===================================================================
--- grok/branches/regebro-guido-templates/src/grok/templatereg.py 2007-10-05 11:41:31 UTC (rev 80634)
+++ grok/branches/regebro-guido-templates/src/grok/templatereg.py 2007-10-05 12:32:44 UTC (rev 80635)
@@ -38,7 +38,7 @@
template_name, extension = os.path.splitext(template_file)
extension = extension[1:] # Get rid of the leading dot.
template_factory = zope.component.queryUtility(
- grok.interfaces.ITemplateFactory,
+ grok.interfaces.ITemplateFileFactory,
name=extension)
if template_factory is None:
@@ -73,7 +73,7 @@
class PageTemplateFileFactory(grok.GlobalUtility):
- grok.implements(grok.interfaces.ITemplateFactory)
+ grok.implements(grok.interfaces.ITemplateFileFactory)
grok.name('pt')
def __call__(self, filename, _prefix=None):
More information about the Checkins
mailing list