Changeset 5977

Show
Ignore:
Timestamp:
09/06/10 16:05:17 (1 year ago)
Author:
ed
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/biz/RemoteBizobj.py

    r5047 r5977  
    1111 
    1212 
    13 cacheDir = os.path.join(os.getcwd(), "cache") 
    14  
    15 def _createCacheDir(): 
    16     if not os.path.exists(cacheDir): 
    17         os.makedirs(cacheDir) 
    18  
    19  
    2013 
    2114class RemoteBizobj(dBizobj): 
     15    cacheDir = None 
     16 
    2217    def _beforeInit(self): 
    2318        return super(RemoteBizobj, self)._beforeInit() 
     
    2924        self.defineConnection() 
    3025        super(RemoteBizobj, self)._afterInit() 
     26 
     27 
     28    @classmethod 
     29    def _createCacheDir(cls, pth=None): 
     30        if cls.cacheDir is not None: 
     31            return 
     32        if pth is None: 
     33            pth = os.getcwd() 
     34        cls.cacheDir = os.path.join(pth, "cache") 
     35        if not os.path.exists(cls.cacheDir): 
     36            os.makedirs(cls.cacheDir) 
    3137 
    3238 
     
    4450 
    4551    @classmethod 
    46     def load(cls, hashval, ds): 
     52    def load(cls, hashval, ds, pth): 
    4753        biz = cls() 
    4854        biz.DataSource = ds 
    4955        biz.hashval = hashval 
    5056 
    51         _createCacheDir(
    52         pth = os.path.join(cacheDir, hashval) 
     57        cls._createCacheDir(pth
     58        pth = os.path.join(cls.cacheDir, hashval) 
    5359        if os.path.exists(pth): 
    5460            f = file(pth) 
     
    8894        is needed. 
    8995        """ 
    90         _createCacheDir() 
    91         pth = os.path.join(cacheDir, hashval) 
     96        self._createCacheDir() 
     97        pth = os.path.join(self.cacheDir, hashval) 
    9298        f = file(pth, "w") 
    9399        pd = {}