dabo Commit
Revision 4890
Date: 2008-12-27 10:01:49 -0800 (Sat, 27 Dec 2008)
Author: Paul
Trac: http://trac.dabodev.com/changeset/4890

Changed:
U   trunk/dabo/dApp.py

Log:
App.HomeDirectory should return the path where the App subclass lives, but it 
wasn't doing that in all cases. This should fix it, although I need to test
this on Windows and Mac, and with bundled applications still. We may need to
check the return value of the inspect.getabspath() call, or wrap it in a try
block, but let's wait and see what we find.



Diff:
Modified: trunk/dabo/dApp.py
===================================================================
--- trunk/dabo/dApp.py  2008-12-27 17:41:07 UTC (rev 4889)
+++ trunk/dabo/dApp.py  2008-12-27 18:01:49 UTC (rev 4890)
@@ -1328,13 +1328,27 @@
                        # that the first entry is not a valid directory. Go 
through the path
                        # and use the first valid directory.
                        hd = None
-                       for pth in sys.path:
-                               if os.path.exists(os.path.join(pth, ".")):
-                                       hd = pth
-                                       break
+
+                       # This first way is the only thing we should really 
use, because it
+                       # gets the path of the App directory. However, if it 
doesn't work, 
+                       # we'll use the old methods below.
+                       hd = 
os.path.split(inspect.getabsfile(self.__class__))[0]
+
+                       # This way isn't ideal because it simply returns the 
first valid
+                       # path in sys.path. This could be the app directory, 
but may not be.
+                       if hd is None:
+                               for pth in sys.path:
+                                       if os.path.exists(os.path.join(pth, 
".")):
+                                               hd = pth
+                                               warnings.warn(Warning, 
_("Setting App.HomeDirectory based on sys.path"))
+                                               break
+
+                       # This way is really lame and shouldn't even be here, 
as it merely
+                       # sets HomeDirectory to the current working directory.
                        if hd is None or len(hd.strip()) == 0:
                                # punt:
                                hd = os.getcwd()
+                               warnings.warn(Warning, _("Setting 
App.HomeDirectory based on os.getcwd()"))
 
                        if os.path.split(hd)[1][-4:].lower() in (".zip", 
".exe"):
                                # mangle HomeDirectory to not be the py2exe 
library.zip file,




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to