/usr/lib64/python2.6/site-packages/Cheetah
NameSizeModeActions
Macros/-0755rm
Templates/-0755rm
Tests/-0755rm
Tools/-0755rm
Utils/-0755rm
CacheRegion.py44210644editdlrm
CacheRegion.pyc66360644editdlrm
CacheRegion.pyo65930644editdlrm
CacheStore.py30470644editdlrm
CacheStore.pyc58750644editdlrm
CacheStore.pyo58750644editdlrm
CheetahWrapper.py238850644editdlrm
CheetahWrapper.pyc229580644editdlrm
CheetahWrapper.pyo228950644editdlrm
Compiler.py802840644editdlrm
Compiler.pyc767540644editdlrm
Compiler.pyo766800644editdlrm
convertTmplPathToModuleName.py4960644editdlrm
convertTmplPathToModuleName.pyc7060644editdlrm
convertTmplPathToModuleName.pyo7060644editdlrm
DirectiveAnalyzer.py24450644editdlrm
DirectiveAnalyzer.pyc40430644editdlrm
DirectiveAnalyzer.pyo40430644editdlrm
Django.py5920644editdlrm
Django.pyc9450644editdlrm
Django.pyo9450644editdlrm
DummyTransaction.py32770644editdlrm
DummyTransaction.pyc56720644editdlrm
DummyTransaction.pyo56720644editdlrm
ErrorCatchers.py17550644editdlrm
ErrorCatchers.pyc36100644editdlrm
ErrorCatchers.pyo36100644editdlrm
FileUtils.py106640644editdlrm
FileUtils.pyc134550644editdlrm
FileUtils.pyo134550644editdlrm
Filters.py76390644editdlrm
Filters.pyc86750644editdlrm
Filters.pyo86750644editdlrm
ImportHooks.py44760644editdlrm
ImportHooks.pyc43680644editdlrm
ImportHooks.pyo43680644editdlrm
ImportManager.py175470644editdlrm
ImportManager.pyc172840644editdlrm
ImportManager.pyo172840644editdlrm
NameMapper.py130930644editdlrm
NameMapper.pyc141610644editdlrm
NameMapper.pyo141610644editdlrm
Parser.py1035990644editdlrm
Parser.pyc814660644editdlrm
Parser.pyo812770644editdlrm
Servlet.py34060644editdlrm
Servlet.pyc38840644editdlrm
Servlet.pyo38840644editdlrm
SettingsManager.py103610644editdlrm
SettingsManager.pyc118110644editdlrm
SettingsManager.pyo118110644editdlrm
SourceReader.py90590644editdlrm
SourceReader.pyc119640644editdlrm
SourceReader.pyo119640644editdlrm
Template.py847470644editdlrm
Template.pyc684040644editdlrm
Template.pyo683200644editdlrm
TemplateCmdLineIface.py33110644editdlrm
TemplateCmdLineIface.pyc39860644editdlrm
TemplateCmdLineIface.pyo39860644editdlrm
Unspecified.py2580644editdlrm
Unspecified.pyc8090644editdlrm
Unspecified.pyo8090644editdlrm
Version.py15400644editdlrm
Version.pyc18670644editdlrm
Version.pyo12990644editdlrm
_namemapper.so135760644editdlrm
__init__.py5820644editdlrm
__init__.pyc7560644editdlrm
__init__.pyo7560644editdlrm
Edit: /usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.py (4421B)
# $Id: CacheRegion.py,v 1.3 2006/01/28 04:19:30 tavis_rudd Exp $ ''' Cache holder classes for Cheetah: Cache regions are defined using the #cache Cheetah directive. Each cache region can be viewed as a dictionary (keyed by cacheRegionID) handling at least one cache item (the default one). It's possible to add cacheItems in a region by using the `varyBy` #cache directive parameter as in the following example:: #def getArticle this is the article content. #end def #cache varyBy=$getArticleID() $getArticle($getArticleID()) #end cache The code above will generate a CacheRegion and add new cacheItem for each value of $getArticleID(). ''' try: from hashlib import md5 except ImportError: from md5 import md5 import time import Cheetah.CacheStore class CacheItem(object): ''' A CacheItem is a container storing: - cacheID (string) - refreshTime (timestamp or None) : last time the cache was refreshed - data (string) : the content of the cache ''' def __init__(self, cacheItemID, cacheStore): self._cacheItemID = cacheItemID self._cacheStore = cacheStore self._refreshTime = None self._expiryTime = 0 def hasExpired(self): return (self._expiryTime and time.time() > self._expiryTime) def setExpiryTime(self, time): self._expiryTime = time def getExpiryTime(self): return self._expiryTime def setData(self, data): self._refreshTime = time.time() self._cacheStore.set(self._cacheItemID, data, self._expiryTime) def getRefreshTime(self): return self._refreshTime def getData(self): assert self._refreshTime return self._cacheStore.get(self._cacheItemID) def renderOutput(self): """Can be overridden to implement edge-caching""" return self.getData() or "" def clear(self): self._cacheStore.delete(self._cacheItemID) self._refreshTime = None class _CacheDataStoreWrapper(object): def __init__(self, dataStore, keyPrefix): self._dataStore = dataStore self._keyPrefix = keyPrefix def get(self, key): return self._dataStore.get(self._keyPrefix+key) def delete(self, key): self._dataStore.delete(self._keyPrefix+key) def set(self, key, val, time=0): self._dataStore.set(self._keyPrefix+key, val, time=time) class CacheRegion(object): ''' A `CacheRegion` stores some `CacheItem` instances. This implementation stores the data in the memory of the current process. If you need a more advanced data store, create a cacheStore class that works with Cheetah's CacheStore protocol and provide it as the cacheStore argument to __init__. For example you could use Cheetah.CacheStore.MemcachedCacheStore, a wrapper around the Python memcached API (http://www.danga.com/memcached). ''' _cacheItemClass = CacheItem def __init__(self, regionID, templateCacheIdPrefix='', cacheStore=None): self._isNew = True self._regionID = regionID self._templateCacheIdPrefix = templateCacheIdPrefix if not cacheStore: cacheStore = Cheetah.CacheStore.MemoryCacheStore() self._cacheStore = cacheStore self._wrappedCacheDataStore = _CacheDataStoreWrapper( cacheStore, keyPrefix=templateCacheIdPrefix+':'+regionID+':') self._cacheItems = {} def isNew(self): return self._isNew def clear(self): " drop all the caches stored in this cache region " for cacheItemId in self._cacheItems.keys(): cacheItem = self._cacheItems[cacheItemId] cacheItem.clear() del self._cacheItems[cacheItemId] def getCacheItem(self, cacheItemID): """ Lazy access to a cacheItem Try to find a cache in the stored caches. If it doesn't exist, it's created. Returns a `CacheItem` instance. """ cacheItemID = md5(str(cacheItemID)).hexdigest() if cacheItemID not in self._cacheItems: cacheItem = self._cacheItemClass( cacheItemID=cacheItemID, cacheStore=self._wrappedCacheDataStore) self._cacheItems[cacheItemID] = cacheItem self._isNew = False return self._cacheItems[cacheItemID]