Commits

Daniel Greenfeld  committed aab2bea

explicit import and bugfix

  • Participants
  • Parent commits 24d852e

Comments (0)

Files changed (1)

File visitor/middleware.py

 """
 from django import http
 
-from visitor.visitor_utils import *
+import visitor.visitor_utils as utils
 from visitor import visitor_constants as constants
 
 
     def process_request(self, request):
         """ get or set the visitor cookie """
         # figure out the IP
-        ip_address = ip_address_from_request(request) or 'Unknown'
+        ip_address = utils.ip_address_from_request(request) or 'Unknown'
 
         # we check to see if they have a cookie, if they do we update the stats
         # for the cookie if they don't have a cookie, we create the cookie.
         
         cookie_saved = request.session.get(constants.COOKIE_SAVED, None)
         visitor_key = request.session.get(constants.VISITOR_KEY, None)
-        visitor_key_cookie = get_visitor_cookie_key(request)
+        visitor_key_cookie = utils.get_visitor_cookie_key(request)
         
         # print("cookie saved = %s" % cookie_saved)
         # print("visitor_key = %s" % visitor_key)
         
         if visitor_key_cookie:
             request.session[constants.COOKIE_SAVED] = True
-            visitor = update_visitor(visitor_key_cookie, 
+            visitor = utils.update_visitor(visitor_key_cookie, 
                                      session_key=session_key)
                                      
             if not visitor:
                 # we couldn't find their old cookie, so create a new one.
                 request.session[constants.COOKIE_SAVED] = False
-                visitor = create_visitor(ip_address, session_key)
+                visitor = utils.create_visitor(ip_address, session_key)
                                          
         else:
             request.session[constants.COOKIE_SAVED] = False
-            visitor = create_visitor(ip_address, session_key)
+            visitor = utils.create_visitor(ip_address, session_key)
 
         request.session[constants.VISITOR_KEY] = visitor.visitor_key
         return None
             cookie_saved = request.session.get(constants.COOKIE_SAVED, None)
             visitor_key = request.session.get(constants.VISITOR_KEY, None)
             if not cookie_saved and visitor_key:
-                set_visitor_cookie_from_key(response, visitor_key)
+                utils.set_visitor_cookie_from_key(response, visitor_key)
                 request.session[constants.COOKIE_SAVED] = True
-        return response
+        return response