[Grok-dev] cheetah templates
Milos Negovanovic
milos.negovanovic at googlemail.com
Sun Feb 1 09:05:39 EST 2009
Hi,
Fallowing this tutorial -> http://grok.zope.org/documentation/how-to/plugging-in-new-template-languages
I have these 2 classes:
class CheetahTemplate(grok.components.GrokTemplate):
def setFromString(self, string):
self._template = Template.compile(source=string)
def setFromFilename(self, filename, _prefix=None):
self._template = Template.compile(file=os.path.join(_prefix, filename))
def render(self, view):
return self._template(searchList=[{'view': views}]).respond()
class CheetahTemplateFactory(grok.GlobalUtility):
grok.implements(grok.interfaces.ITemplateFileFactory)
grok.name('tmpl')
def __call__(self, filename, _prefix=None):
return CheetahTemplate(filename=filename, _prefix=_prefix)
This throws the fallowing error when starting grok/zope:
(virtualgrok)milosn at mighty zazoocms $ ./bin/zopectl fg
/home/milosn/projects/python/grok/zazoocms/parts/app/runzope -C /home/milosn/projects/python/grok/zazoocms/parts/zopectl/zope.conf
Traceback (most recent call last):
File "/home/milosn/projects/python/grok/zazoocms/parts/app/runzope", line 124, in <module>
zope.app.twisted.main.main()
File "/home/milosn/.buildout/eggs/zope.app.twisted-3.4.1-py2.5.egg/zope/app/twisted/main.py", line 74, in main
service = setup(load_options(args))
File "/home/milosn/.buildout/eggs/zope.app.twisted-3.4.1-py2.5.egg/zope/app/twisted/main.py", line 145, in setup
zope.app.appsetup.config(options.site_definition, features=features)
File "/home/milosn/.buildout/eggs/zope.app.appsetup-3.4.1-py2.5.egg/zope/app/appsetup/appsetup.py", line 111, in config
context = xmlconfig.file(file, context=context, execute=execute)
File "/home/milosn/.buildout/eggs/zope.configuration-3.4.0-py2.5.egg/zope/configuration/xmlconfig.py", line 610, in file
include(context, name, package)
File "/home/milosn/.buildout/eggs/zope.configuration-3.4.0-py2.5.egg/zope/configuration/xmlconfig.py", line 546, in include
processxmlfile(f, context)
File "/home/milosn/.buildout/eggs/zope.configuration-3.4.0-py2.5.egg/zope/configuration/xmlconfig.py", line 378, in processxmlfile
parser.parse(src)
File "/usr/pkg/lib/python2.5/xml/sax/expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/pkg/lib/python2.5/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/usr/pkg/lib/python2.5/xml/sax/expatreader.py", line 207, in feed
self._parser.Parse(data, isFinal)
File "/usr/pkg/lib/python2.5/xml/sax/expatreader.py", line 349, in end_element_ns
self._cont_handler.endElementNS(pair, None)
File "/home/milosn/.buildout/eggs/zope.configuration-3.4.0-py2.5.egg/zope/configuration/xmlconfig.py", line 357, in endElementNS
self.context.end()
File "/home/milosn/.buildout/eggs/zope.configuration-3.4.0-py2.5.egg/zope/configuration/config.py", line 542, in end
self.stack.pop().finish()
File "/home/milosn/.buildout/eggs/zope.configuration-3.4.0-py2.5.egg/zope/configuration/config.py", line 690, in finish
actions = self.handler(context, **args)
File "/home/milosn/.buildout/eggs/zope.configuration-3.4.0-py2.5.egg/zope/configuration/xmlconfig.py", line 546, in include
processxmlfile(f, context)
File "/home/milosn/.buildout/eggs/zope.configuration-3.4.0-py2.5.egg/zope/configuration/xmlconfig.py", line 378, in processxmlfile
parser.parse(src)
File "/usr/pkg/lib/python2.5/xml/sax/expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/pkg/lib/python2.5/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/usr/pkg/lib/python2.5/xml/sax/expatreader.py", line 207, in feed
self._parser.Parse(data, isFinal)
File "/usr/pkg/lib/python2.5/xml/sax/expatreader.py", line 349, in end_element_ns
self._cont_handler.endElementNS(pair, None)
File "/home/milosn/.buildout/eggs/zope.configuration-3.4.0-py2.5.egg/zope/configuration/xmlconfig.py", line 357, in endElementNS
self.context.end()
File "/home/milosn/.buildout/eggs/zope.configuration-3.4.0-py2.5.egg/zope/configuration/config.py", line 542, in end
self.stack.pop().finish()
File "/home/milosn/.buildout/eggs/zope.configuration-3.4.0-py2.5.egg/zope/configuration/config.py", line 690, in finish
actions = self.handler(context, **args)
File "/home/milosn/.buildout/eggs/grokcore.component-1.5.1-py2.5.egg/grokcore/component/zcml.py", line 48, in grokDirective
do_grok(package.__name__, _context)
File "/home/milosn/.buildout/eggs/grokcore.component-1.5.1-py2.5.egg/grokcore/component/zcml.py", line 53, in do_grok
config=config
File "/home/milosn/.buildout/eggs/martian-0.11-py2.5.egg/martian/core.py", line 201, in grok_dotted_name
grok_package(module_info, grokker, **kw)
File "/home/milosn/.buildout/eggs/martian-0.11-py2.5.egg/martian/core.py", line 206, in grok_package
grok_package(sub_module_info, grokker, **kw)
File "/home/milosn/.buildout/eggs/martian-0.11-py2.5.egg/martian/core.py", line 204, in grok_package
grok_module(module_info, grokker, **kw)
File "/home/milosn/.buildout/eggs/martian-0.11-py2.5.egg/martian/core.py", line 209, in grok_module
grokker.grok(module_info.dotted_name, module_info.getModule(),
File "/home/milosn/.buildout/eggs/martian-0.11-py2.5.egg/martian/scan.py", line 118, in getModule
self._module = resolve(self.dotted_name)
File "/home/milosn/.buildout/eggs/martian-0.11-py2.5.egg/martian/scan.py", line 191, in resolve
__import__(used)
File "/home/milosn/projects/python/grok/zazoocms/src/zazoocms/app.py", line 497, in <module>
class CheetahTemplate(grok.components.GrokTemplate):
zope.configuration.xmlconfig.ZopeXMLConfigurationError: File "/home/milosn/projects/python/grok/zazoocms/parts/app/site.zcml", line 4.0-4.30
ZopeXMLConfigurationError: File "/home/milosn/projects/python/grok/zazoocms/src/zazoocms/configure.zcml", line 5.2-5.27
AttributeError: 'module' object has no attribute 'GrokTemplate'
Where can I find recent tutorial on this subject? GrokTemplate has
obviously been moved.
Regards
--
Milos Negovanovic
milos.negovanovic at googlemail.com
More information about the Grok-dev
mailing list