mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
Added default return value to Cache.get
This commit is contained in:
parent
f7703ff992
commit
8367707a7b
@ -22,6 +22,7 @@ encoding//src/uds/auths/InternalDB/__init__.py=utf-8
|
||||
encoding//src/uds/auths/RegexLdap/Authenticator.py=utf-8
|
||||
encoding//src/uds/auths/RegexLdap/__init__.py=utf-8
|
||||
encoding//src/uds/auths/SAML-enterprise/SAML.py=utf-8
|
||||
encoding//src/uds/auths/SAML-enterprise/__init__.py=utf-8
|
||||
encoding//src/uds/auths/SAML/SAML.py=utf-8
|
||||
encoding//src/uds/auths/SAML/__init__.py=utf-8
|
||||
encoding//src/uds/auths/Sample/SampleAuth.py=utf-8
|
||||
@ -112,6 +113,9 @@ encoding//src/uds/services/Sample/SampleService.py=utf-8
|
||||
encoding//src/uds/services/Sample/SampleUserDeploymentOne.py=utf-8
|
||||
encoding//src/uds/services/Sample/SampleUserDeploymentTwo.py=utf-8
|
||||
encoding//src/uds/services/Sample/__init__.py=utf-8
|
||||
encoding//src/uds/services/Vmware-enterprise/ServiceProviderVC.py=utf-8
|
||||
encoding//src/uds/services/Vmware-enterprise/VCLinkedCloneService.py=utf-8
|
||||
encoding//src/uds/services/Vmware-enterprise/__init__.py=utf-8
|
||||
encoding//src/uds/services/Vmware/Helpers.py=utf-8
|
||||
encoding//src/uds/services/Vmware/PublicationVC.py=utf-8
|
||||
encoding//src/uds/services/Vmware/ServiceProviderVC.py=utf-8
|
||||
|
@ -53,7 +53,7 @@ class Cache(object):
|
||||
h.update(self._owner + key)
|
||||
return h.hexdigest()
|
||||
|
||||
def get(self,skey):
|
||||
def get(self,skey, defValue = None):
|
||||
now = getSqlDatetime()
|
||||
#logger.debug('Requesting key "%s" for cache "%s"' % (skey, self._owner,))
|
||||
try:
|
||||
@ -61,12 +61,12 @@ class Cache(object):
|
||||
c = dbCache.objects.get(pk=key)
|
||||
expired = now > c.created + timedelta(seconds = c.validity)
|
||||
if expired:
|
||||
return None
|
||||
return defValue
|
||||
val = cPickle.loads(c.value.decode(Cache.CODEC))
|
||||
return val
|
||||
except dbCache.DoesNotExist:
|
||||
logger.debug('key not found')
|
||||
return None
|
||||
return defValue
|
||||
|
||||
def remove(self,skey):
|
||||
#logger.debug('Removing key "%s" for uService "%s"' % (skey, self._owner))
|
||||
|
Loading…
Reference in New Issue
Block a user