On 18 ene, 21:45, Alberto Valverde <[EMAIL PROTECTED]> wrote:
On Jan 18, 2007, at 9:33 PM, stane wrote:
> import os
> import pkg_resources

>    def load_template(self, template_name, template_string=None):
>        """Loads a template from a file or a string"""

>        divider = template_name.rfind(".")
>        if divider > -1:
>            package = template_name[0:divider]
>            basename = template_name[divider+1:]
>        else:
>            raise ValueError, "All templates must be in a package"

>        template_file_path = pkg_resources.resource_filename(package,
>                                                        "%s.%s" %
> (basename,self.extension))
>        mdir,mfile=os.path.split(template_file_path)
>        if mdir not in self.lookup.directories:
>            self.lookup.directories.append(mdir)

>        if not self.lookup.module_directory:

> self.lookup.module_directory=os.path.join(mdir,'mako_modules')

>        # Lookup template
>        return self.lookup.get_template(mfile)Hmmm, that would break 
ToscaWidgets' support for mako... why are you
ignoring the template_string argument to load_template?

Another problem I've just noticed. You're modifying the plugin's
attributes when loading templates.

Turbogears (Pylons and ToscaWidgets too) only instantiates the plugin
once at app startup (not on every render) so changing the plugin's
state on every request wouldn't be thread-safe (ie. will mysteriously
break under load when used concurrently by various users).

I think you could safely change those attributes by patching (or
monkey-patching) turbogears.view.load_engines which is called once on
app startup.

Alberto


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to