def process_request(self, request):
        latitude = None
        longitude = None
        accuracy = None

        # If the request has latitude and longitude query params, use those
        if 'latitude' in request.GET and 'longitude' in request.GET:
            latitude = request.GET['latitude']
            longitude = request.GET['longitude']
            accuracy = request.GET.get('accuracy')

        # Else look for an X-Current-Location header with the format
        # X-Current-Location: latitude=0.0,longitude=0.0,accuracy=1
        elif 'HTTP_X_CURRENT_LOCATION' in request.META:
            location_string = request.META['HTTP_X_CURRENT_LOCATION']
            try:
                temp_dict = dict([token.split('=') for token in location_string.split(',')])
                if 'latitude' in temp_dict and 'longitude' in temp_dict:
                    latitude = temp_dict['latitude']
                    longitude = temp_dict['longitude']
                    accuracy = temp_dict.get('accuracy')
            except __HOLE__:
                # Malformed X-Current-Location header (e.g. latitude=0.0&foo)
                pass
                
        # Else use a geolocation:location session variable
        elif 'geolocation:location' in request.session:
            longitude, latitude = request.session['geolocation:location']
            accuracy = request.session.get('geolocation:accuracy')

        if latitude and longitude:
            point = Point(float(longitude), float(latitude), srid=4326)
            if accuracy:
                accuracy = float(accuracy)
            else:
                accuracy = None
            request.user_location = Location(point, accuracy)
dataset/ETHPy150Open mollyproject/mollyproject/molly/utils/middleware.py/LocationMiddleware.process_request