summaryrefslogtreecommitdiffstats
path: root/wallace/module_resources.py
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-03-06 06:17:54 -0500
committerThomas Bruederli <bruederli@kolabsys.com>2014-03-06 06:17:54 -0500
commit7bd1d324254b08e1366f734cf168422d08b297c7 (patch)
tree9b4e59493f961a2dd1ca50258730b653288b3205 /wallace/module_resources.py
parentb6fe11ce3ea308ed4fcaaa2e3b297eb3899cb277 (diff)
downloadpykolab-7bd1d324254b08e1366f734cf168422d08b297c7.tar.gz
Optimization: only connect to LDAP and IMAP when actually necessary
Diffstat (limited to 'wallace/module_resources.py')
-rw-r--r--wallace/module_resources.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/wallace/module_resources.py b/wallace/module_resources.py
index 4202098..302f276 100644
--- a/wallace/module_resources.py
+++ b/wallace/module_resources.py
@@ -96,10 +96,7 @@ def execute(*args, **kw):
log.debug(_("Resource Management called for %r, %r") % (args, kw), level=9)
auth = Auth()
- auth.connect()
-
imap = IMAP()
- imap.connect()
# TODO: Test for correct call.
filepath = args[0]
@@ -182,6 +179,8 @@ def execute(*args, **kw):
possibly_any_resources = False
if possibly_any_resources:
+ auth.connect()
+
for recipient in recipients:
if not len(resource_record_from_email_address(recipient)) == 0:
resource_recipient = recipient
@@ -234,6 +233,7 @@ def execute(*args, **kw):
log.debug(_("Resources: %r; %r") % (resource_dns, resources), level=8)
+ imap.connect()
done = False
receiving_resource = resources[resource_dns[0]]