dabo Commit
Revision 4805
Date: 2008-12-08 11:44:24 -0800 (Mon, 08 Dec 2008)
Author: Ed
Trac: http://trac.dabodev.com/dabo/changeset/4805

Changed:
U   trunk/dabo/dApp.py
U   trunk/dabo/lib/connParser.py

Log:
Fixed a bug reported by Christoph Zwerschke in issue #1186 when non-file-based 
database names conflict with local file names.

Improved the code in dApp that imports connections. Previously, if the app was 
started from the home directory, each connection would be called twice.



Diff:
Modified: trunk/dabo/dApp.py
===================================================================
--- trunk/dabo/dApp.py  2008-12-08 18:42:01 UTC (rev 4804)
+++ trunk/dabo/dApp.py  2008-12-08 19:44:24 UTC (rev 4805)
@@ -869,8 +869,8 @@
                #               pth/db
                #               pth/data
                
-               dbDirs = (hd, os.path.join(hd, "db"), os.path.join(hd, "data"), 
-                               pth, os.path.join(pth, "db"), os.path.join(pth, 
"data"))
+               dbDirs = set((hd, os.path.join(hd, "db"), os.path.join(hd, 
"data"), 
+                               pth, os.path.join(pth, "db"), os.path.join(pth, 
"data")))
                for dbDir in dbDirs:
                        if os.path.exists(dbDir) and os.path.isdir(dbDir):
                                files = glob.glob(os.path.join(dbDir, 
"*.cnxml"))

Modified: trunk/dabo/lib/connParser.py
===================================================================
--- trunk/dabo/lib/connParser.py        2008-12-08 18:42:01 UTC (rev 4804)
+++ trunk/dabo/lib/connParser.py        2008-12-08 19:44:24 UTC (rev 4805)
@@ -7,7 +7,11 @@
 import dabo
 import dabo.lib.utils as utils
 
+# Tuple containing all file-based database types.
+FILE_DATABASES = ("sqlite", )
 
+
+
 class connHandler(xml.sax.ContentHandler):
        def __init__(self):
                self.connDict = {}
@@ -64,16 +68,18 @@
        ch = connHandler()
        xml.sax.parse(f, ch)
        ret = ch.getConnectionDict()
-       
+
        for cxn, data in ret.items():
-               for key, val in data.items():
-                       if key=="database":
-                               osp = os.path
-                               relpath = utils.resolvePath(val, pth, 
abspath=False)
-                               pth = pth.decode(sys.getfilesystemencoding())
-                               abspath = 
osp.abspath(osp.join(osp.split(pth)[0], relpath))
-                               if osp.exists(abspath):
-                                       ret[cxn][key] = abspath 
+               dbtype = data.get("dbtype", "")
+               if dbtype.lower() in FILE_DATABASES:
+                       for key, val in data.items():
+                               if key=="database":
+                                       osp = os.path
+                                       relpath = utils.resolvePath(val, pth, 
abspath=False)
+                                       pth = 
pth.decode(sys.getfilesystemencoding())
+                                       abspath = 
osp.abspath(osp.join(osp.split(pth)[0], relpath))
+                                       if osp.exists(abspath):
+                                               ret[cxn][key] = abspath 
        return ret
 
 




_______________________________________________
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