|
@@ -52,9 +52,12 @@ recent_access_map = { }
|
|
|
_recent_access_map_lk = threading.Lock()
|
|
_recent_access_map_lk = threading.Lock()
|
|
|
_per_user_lk = { } # Indexed by username
|
|
_per_user_lk = { } # Indexed by username
|
|
|
|
|
|
|
|
-# Store the IP address of users
|
|
|
|
|
|
|
+# Store a map of usernames and their IP addresses
|
|
|
remote_ip_map = { }
|
|
remote_ip_map = { }
|
|
|
|
|
|
|
|
|
|
+# Store a map of usernames and last access times
|
|
|
|
|
+recent_access_time_map = { }
|
|
|
|
|
+
|
|
|
# Max number of records per user per view to keep
|
|
# Max number of records per user per view to keep
|
|
|
_USER_ACCESS_HISTORY_SIZE = desktop.conf.USER_ACCESS_HISTORY_SIZE.get()
|
|
_USER_ACCESS_HISTORY_SIZE = desktop.conf.USER_ACCESS_HISTORY_SIZE.get()
|
|
|
|
|
|
|
@@ -100,8 +103,9 @@ class AccessInfo(dict):
|
|
|
app_dict = { }
|
|
app_dict = { }
|
|
|
_per_user_lk[user] = threading.Lock()
|
|
_per_user_lk[user] = threading.Lock()
|
|
|
recent_access_map[user] = app_dict
|
|
recent_access_map[user] = app_dict
|
|
|
- # Update the IP address of the user
|
|
|
|
|
|
|
+ # Update the IP address and last access time of the user
|
|
|
remote_ip_map[user] = self['remote_ip']
|
|
remote_ip_map[user] = self['remote_ip']
|
|
|
|
|
+ recent_access_time_map[user] = self['time']
|
|
|
finally:
|
|
finally:
|
|
|
_recent_access_map_lk.release()
|
|
_recent_access_map_lk.release()
|
|
|
|
|
|
|
@@ -138,7 +142,6 @@ def log_page_hit(request, view_func, level=None):
|
|
|
level = logging.INFO
|
|
level = logging.INFO
|
|
|
ai = AccessInfo(request)
|
|
ai = AccessInfo(request)
|
|
|
ai.log(level)
|
|
ai.log(level)
|
|
|
- ai['remote_ip'] = request.META.get('REMOTE_ADDR', '-')
|
|
|
|
|
# Find the app
|
|
# Find the app
|
|
|
app_re_match = _MODULE_RE.match(view_func.__module__)
|
|
app_re_match = _MODULE_RE.match(view_func.__module__)
|
|
|
app = app_re_match and app_re_match.group(0) or '-'
|
|
app = app_re_match and app_re_match.group(0) or '-'
|