Hi,<br><br>I followed the tutorial in <a href="http://grok.zope.org/documentation/how-to/plugging-in-new-template-languages">http://grok.zope.org/documentation/how-to/plugging-in-new-template-languages</a> and I&#39;m using a combination of Jinja + Yaml + simplejson<br>
to be able to render JSON format from grok.View classes. <br><br>Basically I have something like this:<br><br>from jinja2 import Template<br>import yaml, simplejson, grok, os<br>from grokcore.view.components import GrokTemplate<br>
from grokcore.view.interfaces import ITemplate, ITemplateFileFactory<br><br>class JSONTemplate(GrokTemplate):<br>&nbsp;&nbsp;&nbsp; grok.implements(ITemplate)<br><br>&nbsp;&nbsp;&nbsp; def setFromString(self, string):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self._template = Template(string)<br>
<br>&nbsp;&nbsp;&nbsp; def setFromFilename(self, filename, _prefix=None):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file = open(os.path.join(_prefix, filename))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self._template = Template(file.read())<br><br>&nbsp;&nbsp;&nbsp; def render(self, view):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jinja_render = self._template.render(**self.getNamespace(view))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yaml_loader = yaml.load(jinja_render)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return simplejson.dumps(yaml_loader)<br><br><br>I&#39;m doing this because I want to build an application that only use JSON and some JavaScript framework on the client side (extjs by now). And I didn&#39;t like the way I should use grok.JSON (too much classes and methods).<br>
<br>The question is: is there any way to reload the plugged templates without restart zope? like grok does with default ZPT<br><br>thanks in advance.<br clear="all"><br>-- <br>Santiago Videla<br><a href="http://www.revolucionesweb.com.ar">www.revolucionesweb.com.ar</a><br>
<a href="http://www.linkedin.com/in/svidela">http://www.linkedin.com/in/svidela</a><br><br>Sigue la mata dando de que hablar siempre abajo y a la izquierda donde el pensamiento que se hace corazón resplandece con la palabra sencilla y humilde que l@s tod@s somos.<br>