dabo Commit
Revision 5977
Date: 2010-09-06 16:05:17 -0700 (Mon, 06 Sep 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/5977

Changed:
U   trunk/dabo/biz/RemoteBizobj.py

Log:
Updated the internal cache code to handle permissions better when running under 
mod_wsgi.


Diff:
Modified: trunk/dabo/biz/RemoteBizobj.py
===================================================================
--- trunk/dabo/biz/RemoteBizobj.py      2010-09-05 17:24:02 UTC (rev 5976)
+++ trunk/dabo/biz/RemoteBizobj.py      2010-09-06 23:05:17 UTC (rev 5977)
@@ -10,15 +10,10 @@
 from dBizobj import dBizobj
 
 
-cacheDir = os.path.join(os.getcwd(), "cache")
 
-def _createCacheDir():
-       if not os.path.exists(cacheDir):
-               os.makedirs(cacheDir)
+class RemoteBizobj(dBizobj):
+       cacheDir = None
 
-
-
-class RemoteBizobj(dBizobj):
        def _beforeInit(self):
                return super(RemoteBizobj, self)._beforeInit()
 
@@ -30,6 +25,17 @@
                super(RemoteBizobj, self)._afterInit()
 
 
+       @classmethod
+       def _createCacheDir(cls, pth=None):
+               if cls.cacheDir is not None:
+                       return
+               if pth is None:
+                       pth = os.getcwd()
+               cls.cacheDir = os.path.join(pth, "cache")
+               if not os.path.exists(cls.cacheDir):
+                       os.makedirs(cls.cacheDir)
+
+
        def defineConnection(self):
                """You must define and create the connection in this method. 
Otherwise
                an error will be raised. Pass the connection information to 
setConnectionParams();
@@ -43,13 +49,13 @@
 
 
        @classmethod
-       def load(cls, hashval, ds):
+       def load(cls, hashval, ds, pth):
                biz = cls()
                biz.DataSource = ds
                biz.hashval = hashval
 
-               _createCacheDir()
-               pth = os.path.join(cacheDir, hashval)
+               cls._createCacheDir(pth)
+               pth = os.path.join(cls.cacheDir, hashval)
                if os.path.exists(pth):
                        f = file(pth)
                        kf, crsData = pickle.load(f)
@@ -87,8 +93,8 @@
                """Store data info to the cache for the next time the same 
bizobj
                is needed.
                """
-               _createCacheDir()
-               pth = os.path.join(cacheDir, hashval)
+               self._createCacheDir()
+               pth = os.path.join(self.cacheDir, hashval)
                f = file(pth, "w")
                pd = {}
                cursorDict = self._cursorDictReference()



_______________________________________________
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