Re: ImportHooks vs imp
Богун Дмитрий <[email protected]> Fri, 16 Jul 2010 22:54:42 +0300
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
В Чтв, 15/07/2010 в 14:10 -0700, Tavis Rudd пишет: > Hi, > 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. > Tavis Now I too can see this. 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. > > ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Cheetahtemplate-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
cheetah-import-hook.tar.bz2
(application/x-bzip-compressed-tar, 2.6 KB) - not displayed