summaryrefslogtreecommitdiff
blob: a2900305ae0bdd52088e4f22e065bf6da00d66a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
diff --git a/src/automx/config.py b/src/automx/config.py
index 48a8e16..a79fb34 100644
--- a/src/automx/config.py
+++ b/src/automx/config.py
@@ -27,9 +27,14 @@ import subprocess
 import shlex
 import StringIO
 import re
-import memcache
 import logging
 
+try:
+    import memcache
+    use_memcache = True
+except ImportError:
+    use_memcache = False
+
 from ConfigParser import NoOptionError, NoSectionError
 from ipaddr import IPAddress, IPNetwork
 from dateutil import parser
@@ -849,7 +854,7 @@ class Memcache(object):
         return self.__current
 
     def set_client(self):
-        if not self.__has_memcache:
+        if not self.__has_memcache or use_memcache is False:
             return
 
         if self.__is_trusted_network():
@@ -870,7 +875,7 @@ class Memcache(object):
         self.__mc.set(self.__client, self.__current, time=ttl)
                                                             
     def allow_client(self):
-        if not self.__has_memcache:
+        if not self.__has_memcache or use_memcache is False:
             return True
 
         self.__client = self.__environ["REMOTE_ADDR"]
@@ -914,4 +919,4 @@ class Memcache(object):
         
         return False
 
-# vim: expandtab ts=4 sw=4
\ No newline at end of file
+# vim: expandtab ts=4 sw=4