diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-09-16 18:23:51 (GMT) |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-09-16 18:24:31 (GMT) |
commit | 5f9f8c0e529bceee589277c5475508e91f146b64 (patch) | |
tree | 012a7aaebcf30eb5d06241db1178b82549efbb41 | |
parent | 6394ca55d3a9700515face96bbb52004fcda7086 (diff) | |
download | pykolab-5f9f8c0e529bceee589277c5475508e91f146b64.tar.gz |
Re-enable and tweak the kolab_smtp_access_policy cache
-rwxr-xr-x | bin/kolab_smtp_access_policy.py | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/bin/kolab_smtp_access_policy.py b/bin/kolab_smtp_access_policy.py index bd94925..bce2614 100755 --- a/bin/kolab_smtp_access_policy.py +++ b/bin/kolab_smtp_access_policy.py @@ -629,24 +629,15 @@ class PolicyRequest(object): # Got a final answer here, do the caching thing. if not cache == False: - records = cache_select( + record_id = cache_update( function='verify_sender', sender=self.sender, recipients=self.recipients, + result=(int)(False), sasl_username=self.sasl_username, sasl_sender=self.sasl_sender ) - if not len(records) == len(self.recipients): - record_id = cache_insert( - function='verify_sender', - sender=self.sender, - recipients=self.recipients, - result=(int)(False), - sasl_username=self.sasl_username, - sasl_sender=self.sasl_sender - ) - sender_is_delegate = False else: @@ -1051,24 +1042,15 @@ class PolicyRequest(object): sender_verified = True if not cache == False: - records = cache_select( + record_id = cache_update( function='verify_sender', sender=self.sender, recipients=self.recipients, + result=(int)(sender_verified), sasl_username=self.sasl_username, - sasl_sender=self.sasl_sender, + sasl_sender=self.sasl_sender ) - if len(records) == len(self.recipients): - record_id = cache_insert( - function='verify_sender', - sender=self.sender, - recipients=self.recipients, - result=(int)(sender_verified), - sasl_username=self.sasl_username, - sasl_sender=self.sasl_sender - ) - return sender_verified def cache_cleanup(): @@ -1085,11 +1067,9 @@ def cache_cleanup(): def cache_init(): global cache, cache_expire, session - return False - if conf.has_section('kolab_smtp_access_policy'): - if conf.has_option('kolab_smtp_access_policy', 'uri'): - cache_uri = conf.get('kolab_smtp_access_policy', 'uri') + if conf.has_option('kolab_smtp_access_policy', 'cache_uri'): + cache_uri = conf.get('kolab_smtp_access_policy', 'cache_uri') cache = True if conf.has_option('kolab_smtp_access_policy', 'retention'): cache_expire = (int)( @@ -1098,7 +1078,10 @@ def cache_init(): 'retention' ) ) - + elif conf.has_option('kolab_smtp_access_policy', 'uri'): + log.warning(_("The 'uri' setting in the kolab_smtp_access_policy section is soon going to be deprecated in favor of 'cache_uri'")) + cache_uri = conf.get('kolab_smtp_access_policy', 'uri') + cache = True else: return False else: |