diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-09-16 19:23:51 +0100 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-09-16 19:23:51 +0100 |
commit | 23f28a7a1ce96532dc22b434d5b092e27e65d175 (patch) | |
tree | 5936bacd305f187d4888e042446b36cac66d51a1 /bin/kolab_smtp_access_policy.py | |
parent | 21098a6cb023fa3cf95b1477d6e3e4608bfec6ff (diff) | |
download | pykolab-23f28a7a1ce96532dc22b434d5b092e27e65d175.tar.gz |
Re-enable and tweak the kolab_smtp_access_policy cache
Diffstat (limited to 'bin/kolab_smtp_access_policy.py')
-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 45676b4..49319c1 100755 --- a/bin/kolab_smtp_access_policy.py +++ b/bin/kolab_smtp_access_policy.py @@ -628,24 +628,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: @@ -1039,24 +1030,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(): @@ -1073,11 +1055,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)( @@ -1086,7 +1066,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: |