Hi Ethan,
As it currently exists, py:extends doesn't provide a lot of dynamic
overrideability. It probably *could*, but it's tricky because Kid
generates Python classes. Markup is encouraging in this respect, in
that it can easily handle dynamic behavior. (xi:include="${foo}"
works!) Of course, if you're using slots that's not an easy transition.
Kevin
On Aug 13, 2006, at 1:13 PM, mindlace wrote:
>
> Gentlebeings,
>
> I have searched mightily for the reason why "from templates import
> template" doesn't work inside a template, or in a controller even. I
> haven't figured it out. I have come up with a hopelessly heavy
> solution, but would appreciate being told what the simple way is.
>
> However, I have found baseTemplates in turbogears.view.base , but it
> gets initialized rediculously early in the life of a TG site. The best
> I was able to come up with for overriding the list is:
>
> #my project name is xui
> #start-xui.py this all has to happen before 'import turbogears'.
> import os, inspect
> template_list = []
> here = split(abspath(inspect.getfile(sys._getframe(0))))[0]
> tplaces = ['xui/templates','xui/templates/pieces']
> for place in tplaces:
> for fname in os.listdir(join(here,place)):
> if fname[-3:] == 'kid':
> template_list.append(place.replace('/','.')+'.'+fname
> [:-4])
>
> import turbogears.view.base
> turbogears.view.base.baseTemplates = template_list
>
> But that seems like a royal fustercluck to me. So I assume the
> community handles this situation in a more intelligent manner.
>
> I have pages that have a number of "slots", each of which could be
> filled by a different template (widget, if you prefer) depending on
> the
> context. Options I explored included:
>
> a.) importing templates in the controller and then handing them off in
> the return dict. I get import errors, if I'm remembering right.
>
> b.) importing templates in another template. This led me to the above.
>
> c.) implementing a controller method, find_templates() and doing
> py:extends="c.find_templates()". This seems to work, 'cepting that my
> controller can't seem to import things either.
>
> If I need to programatically assemble templates, how should I be doing
> it?
>
> Thanks for your help,
> ~ethan fremen
>
>
> >
--
Kevin Dangoor
TurboGears / Zesty News
email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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
-~----------~----~----~----~------~----~------~--~---