'Record this user access to the recent access map'

def add_to_access_history(self, app):

    self['app'] = app
    user = self['username']
    path = self['path']
    try:
        app_dict = recent_access_map[user]
    except KeyError:
        _recent_access_map_lk.acquire()
        try:
            app_dict = {}
            _per_user_lk[user] = threading.Lock()
            recent_access_map[user] = app_dict
        finally:
            _recent_access_map_lk.release()
    user_lk = _per_user_lk[user]
    user_lk.acquire()
    try:
        try:
            path_dict = app_dict[app]
        except KeyError:
            path_dict = {}
            app_dict[app] = path_dict
        try:
            view_access_list = path_dict[path]
        except KeyError:
            view_access_list = []
            path_dict[path] = view_access_list
        view_access_list.insert(0, self)
        if (len(view_access_list) > _USER_ACCESS_HISTORY_SIZE):
            view_access_list.pop()
        last_access_map[user] = {'ip': self['remote_ip'], 'time': self['time']}
    finally:
        user_lk.release()
