[Grok-dev] megrok.genshi
Lennart Regebro
regebro at gmail.com
Mon Mar 9 15:45:31 EDT 2009
Looks good.
On Fri, Mar 6, 2009 at 11:13, Shane Hathaway <shane at hathawaymix.org> wrote:
> Grokstars,
>
> I just tried out megrok.genshi (along with the rest of Grok, which is
> looking good, BTW). It didn't work until I patched it. The patch below
> fixes two problems:
>
> - Grok 1.0a1 doesn't have an interface named ITemplateFileFactory in
> grok.interface. The interface is located in grokcore.view.interfaces.
>
> - Auto-reload didn't work.
>
> Should I check in this change?
>
> Shane
>
>
> Index: components.py
>
> ===================================================================
>
> --- components.py (revision 97554)
>
> +++ components.py (working copy)
>
> @@ -15,20 +15,23 @@
>
> import zope.interface
>
> import genshi.template
>
> import grokcore.view.components
>
> +import grokcore.view.interfaces
>
> import grok
>
>
>
> class GenshiTemplateBase(grokcore.view.components.GrokTemplate):
>
> -
>
> +
>
> def render(self, view):
>
> - stream = self._template.generate(**self.getNamespace(view))
>
> + template = self._get_template()
>
> + stream = template.generate(**self.getNamespace(view))
>
> return stream.render(self.result_type)
>
>
>
> def setFromString(self, string):
> - self._template = self.cls(string)
> -
> + template = self.cls(string)
> + self._get_template = lambda: template
> +
> def setFromFilename(self, filename, _prefix=None):
> - loader = genshi.template.TemplateLoader(_prefix)
> - self._template = loader.load(filename, cls=self.cls)
> + loader = genshi.template.TemplateLoader(_prefix, auto_reload=True)
> + self._get_template = lambda: loader.load(filename, cls=self.cls)
>
> class GenshiMarkupTemplate(GenshiTemplateBase):
>
> @@ -42,7 +45,7 @@
>
> class GenshiMarkupTemplateFactory(grok.GlobalUtility):
>
> - zope.interface.implements(grok.interfaces.ITemplateFileFactory)
> +
> zope.interface.implements(grokcore.view.interfaces.ITemplateFileFactory)
> grok.name('g')
>
> def __call__(self, filename, _prefix=None):
> @@ -50,7 +53,7 @@
>
> class GenshiTextTemplateFactory(grok.GlobalUtility):
>
> - zope.interface.implements(grok.interfaces.ITemplateFileFactory)
> +
> zope.interface.implements(grokcore.view.interfaces.ITemplateFileFactory)
> grok.name('gt')
>
> def __call__(self, filename, _prefix=None):
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
>
--
Lennart Regebro: Pythonista, Barista, Notsotrista.
http://regebro.wordpress.com/
+33 661 58 14 64
More information about the Grok-dev
mailing list