[Checkins] SVN: z3c.pt/trunk/z3c/pt/pagetemplate.py If module is not __init__.py, it will have a __file__ attribute instead of __path__.

Malthe Borch mborch at gmail.com
Sat Feb 23 21:50:25 EST 2008


Log message for revision 84206:
  If module is not __init__.py, it will have a __file__ attribute instead of __path__.

Changed:
  U   z3c.pt/trunk/z3c/pt/pagetemplate.py

-=-
Modified: z3c.pt/trunk/z3c/pt/pagetemplate.py
===================================================================
--- z3c.pt/trunk/z3c/pt/pagetemplate.py	2008-02-23 23:15:20 UTC (rev 84205)
+++ z3c.pt/trunk/z3c/pt/pagetemplate.py	2008-02-24 02:50:24 UTC (rev 84206)
@@ -88,7 +88,13 @@
     def __init__(self, filename):
         if not os.path.isabs(filename):
             package_name = sys._getframe(1).f_globals['__name__']
-            path = sys.modules[package_name].__path__[0]
+            module = sys.modules[package_name]
+            try:
+                path = module.__path__[0]
+            except AttributeError:
+                path = module.__file__
+                path = path[:path.rfind(os.sep)]
+                
             filename = path + os.sep + filename
 
         # make sure file exists



More information about the Checkins mailing list