[Checkins] SVN: z3c.pt/trunk/src/z3c/pt/template.py Try to infer
module path on two levels;
this allows declaring templates outside of classes (e.g. in a
module-level function).
Malthe Borch
mborch at gmail.com
Fri Jul 18 08:39:46 EDT 2008
Log message for revision 88496:
Try to infer module path on two levels; this allows declaring templates outside of classes (e.g. in a module-level function).
Changed:
U z3c.pt/trunk/src/z3c/pt/template.py
-=-
Modified: z3c.pt/trunk/src/z3c/pt/template.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/template.py 2008-07-18 12:25:43 UTC (rev 88495)
+++ z3c.pt/trunk/src/z3c/pt/template.py 2008-07-18 12:39:46 UTC (rev 88496)
@@ -101,7 +101,13 @@
BaseTemplate.__init__(self, None)
if not os.path.isabs(filename):
- package_name = sys._getframe(2).f_globals['__name__']
+ for depth in (1, 2):
+ frame = sys._getframe(depth)
+ package_name = frame.f_globals['__name__']
+
+ if package_name != self.__module__:
+ break
+
module = sys.modules[package_name]
try:
path = module.__path__[0]
More information about the Checkins
mailing list