ive been pointed to this:
http://docs.pythonweb.org/display/pysckbook/An+Alternative+ToscaWidgets+Setup+with+Mako
On Mar 15, 6:44 pm, Alberto Valverde <[EMAIL PROTECTED]> wrote:
> On Mar 15, 2007, at 10:51 PM, Michael Bayer wrote:
>
>
>
> > easy enough to see this example, taken from the unit tests (whats the
> > proper way to run the unit tests individually, btw ?), function:
>
> Using nose you can do from the svn sandbox root:
>
> nosetests tests.test_render:TestMakoInGenshi.test_display
> or
> nosetests tests.test_render:TestMakoInGenshi
> or
> nosetests tests.test_render
>
>
>
>
>
> > from toscawidgets.core import Widget
>
> > class MakoWidget(Widget):
> > params = ["rows"]
> > rows = []
> > engine_name = "mako"
> > template = """
> > <%page args="id=''" />
> > <table id="${id}">
> > % for row in rows:
> > ${makerow(row)}
> > % endfor
> > </table>
>
> > <%def name="makerow(row)">
> > <tr>
> > % for name in row:
> > <td>${name}</td>
> > % endfor
> > </tr>
> > </%def>
> > """
> > def update_params(self,d):
> > Widget.update_params(self,d)
> > if d['value']:
> > d['rows'] = d['value']
>
> > print MakoWidget().display([('foo','bar')]*5)
>
> > however, im using twForms and have a TableForm with a "template"
> > parameter that wants to use TemplateLookup to locate its template.
> > How to pass options along to the mako.ext.TGPlugin so that I can pass
> > the search directories along ?
>
> The HostFramework is in charge of loading and initializing all
> template engines. Currently all HostFrameworks are hardcoded to load
> all template engine with no options when the class is built. You
> could subclass toscawidgets.mods.pylonshf.PylonsHostFramework to
> modify this behaviour and manually load the Mako plugin passing it
> the options you need:
>
> from toscawidgets.view import EngineManager
> from toscawidgets.mods.pylonshf import PylonsHostFramework
>
> class MyHF(PylonsHostFramework):
> engines = EngineManager()
> engines.load_all() #You might not need this if only using mako
> widgets...
> engines.load_engine('mako', {'directories':[...]})
>
> > bonus question, how to integrate those directories to be the same ones
> > used by my Pylons environment ?
>
> I've never used Mako with Pylons but I guess that (assuming the
> plugin is configured inside config.middleware.make_app like the
> recipes for Genshi suggest) you could build the HF there like above
> passing it the same options that were used to initialize Buffet. To
> avoid having two plugin instances around, alternatively you could
> place the same plugin instance that has been configured for Pylons at
> the "mako" key of the Pylons.HostFramework.engines dict subclass.
>
> I'm not very happy with the API for doing this, maybe TW could
> provide a class factory function to simplify this?, something like:
>
> make_host_framework(engines=[('mako', {mako_opts}), ('genshi',
> {genshi_opts}),...])
>
> Alberto
>
> P.S. Cross-posting to the new toscawidgets-discuss ML.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---