Re: [Cheetahtemplate-discuss] ImportHooks vs imp
- В Чтв, 15/07/2010 в 14:10 -0700, Tavis Rudd пишет:
> Hi,Now I too can see this.
> I can't think of any way to do that without either hacking the existing
> ImportHooks module (and I can't think of how you'd achieve what you want)
> or writing a new implementation that works with imp.
I was unable to got from ImportHooks what I want, so I wrote import hook
that allow me reach required behabviour. Theoretically it is possible
whiout custom import hook, just with Cheetah.ImportHoks +
runpy.load_module, but I need more controll over process that
ImportHooks can give me.
My import hook in attache(all expected to be into /tmp). But it is not
vell tested yet.
> > I need to make 2 sets of templates. One generic level, and some count of
> > overlays for gnereric templates.
> > for example I have generic template /tmpl/web/main.tmpl and possible
> > overlays for it /tmpl/_users_/vasya/web/main.tmpl
> > and /tmpl/_users_/petya/web/main.tmpl.
> > Now to load templates I use direct calls to Template.compile and give it
> > required open file descriptor. But this is not very comfortable.
> > I want to try ImportHooks but, because of multiple, dynamically changed
> > search path, I don't want to add all path into sys.path. I want to use
> > imp module to load module from required places... After try I see that
> > ImportHooks and imp can't work together.
> > Into attach my example, where I try to use ImportHooks and imp
> > toogether(_gen.tmpl and t0.tmpl locaten into /tmp/tmpl. empty
> > __init__.py too placed into /tmp/tmpl).
> > Is there a way to use ImportHooks and not place all search path into
> > sys.path?
> > PS Sorry for my English.