class OnlineCounterMiddleware(object):
    def process_request(self, request):
        self.online_counter = OnlineCounter()
        self.online_counter.delete_idle()
        self.online_counter.check_in(request)
        request.online = self

    def total(self):
        total = len(self.online_counter.online_users)
        return total

    def guest(self):
        guest = len(self.online_counter.guests)
        return guest

    def users(self):
        users = len(self.online_counter.users)
        return users
 def process_request(self, request):
     self.online_counter = OnlineCounter()
     self.online_counter.delete_idle()
     self.online_counter.check_in(request)
     request.online = self