dabo Commit
Revision 4721
Date: 2008-11-27 12:58:23 -0800 (Thu, 27 Nov 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4721

Changed:
U   trunk/dabo/dApp.py

Log:
Added the method 'getStandardAppDirectory()'. This takes one of the following 
standard Dabo directory names and returns the path to that directory. It takes 
an optional path location to start looking from; it will also search the app's 
HomeDirectory.

The standard directory names are:
"biz", "cache", "db", "main.py", "reports", "resources", "test", "ui"

If the user requests a non-standard directory, a message is printed to the 
errorLog and None is returned. 

If the specified standard directory cannot be found, None is returned.


Diff:
Modified: trunk/dabo/dApp.py
===================================================================
--- trunk/dabo/dApp.py  2008-11-27 16:36:53 UTC (rev 4720)
+++ trunk/dabo/dApp.py  2008-11-27 20:58:23 UTC (rev 4721)
@@ -1001,6 +1001,34 @@
                                self.dbConnectionNameToFiles[k] = connFile
 
 
+       def getStandardAppDirectory(self, dirname, start=None):
+               """Return the path to one of the standard Dabo application 
directories.
+               If a starting file path is provided, use that first. If not, 
use the 
+               HomeDirectory as the starting point.
+               """
+               stdDirs = ("biz", "cache", "db", "main.py", "reports", 
"resources", "test", "ui")
+               if dirname not in stdDirs:
+                       dabo.errorLog.write(_("Non-standard directory '%s' 
requested") % dirname)
+                       return None
+               osp = os.path
+               if start is not None:
+                       if not osp.isdir(start):
+                               # Use the file's directory
+                               start = osp.split(start)[0]
+               for target in (start, self.HomeDirectory):
+                       if target is None:
+                               continue
+                       pth = osp.join(target, dirname)
+                       if osp.isdir(pth):
+                               return pth
+                       else:
+                               # Try the parent
+                               pth = osp.normpath(osp.join(target, "..", 
dirname))
+                               if osp.isdir(pth):
+                                       return pth
+               return None
+
+
        def getTransactionToken(self, biz):
                """Only one bizobj at a time can begin and end transactions per 
connection. 
                This allows the bizobj to query the app for the 'token', which 
is simply an 




_______________________________________________
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