wallace/module_resources.py

Thomas Brüderli bruederli at kolabsys.com
Mon Mar 10 11:00:54 CET 2014


 wallace/module_resources.py |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 7bd1d324254b08e1366f734cf168422d08b297c7
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Thu Mar 6 06:17:54 2014 -0500

    Optimization: only connect to LDAP and IMAP when actually necessary

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]]




More information about the commits mailing list