def get_rating_for_user(self, user, ip_address=None, cookies={}):
        """get_rating_for_user(user, ip_address=None, cookie=None)
        
        Returns the rating for a user or anonymous IP."""
        kwargs = dict(
            content_type    = self.get_content_type(),
            object_id       = self.instance.pk,
            key             = self.field.key,
        )

        if not (user and user.is_authenticated()):
            if not ip_address:
                raise ValueError('``user`` or ``ip_address`` must be present.')
            kwargs['user__isnull'] = True
            kwargs['ip_address'] = ip_address
        else:
            kwargs['user'] = user
        
        use_cookies = (self.field.allow_anonymous and self.field.use_cookies)
        if use_cookies:
            # TODO: move 'vote-%d.%d.%s' to settings or something
            cookie_name = 'vote-%d.%d.%s' % (kwargs['content_type'].pk, kwargs['object_id'], kwargs['key'][:6],) # -> md5_hexdigest?
            cookie = cookies.get(cookie_name)
            if cookie:    
                kwargs['cookie'] = cookie
            else:
                kwargs['cookie__isnull'] = True
            
        try:
            rating = Vote.objects.get(**kwargs)
            return rating.score
        except Vote.MultipleObjectsReturned:
            pass
        except Vote.DoesNotExist:
            pass
        return
def get_rating_for_user ( self , user , ip_address = None , cookies = { } ) : kwargs = dict ( content_type = self . get_content_type ( ) , object_id = self . instance . pk , key = self . field . key , ) if not ( user and user . is_authenticated ( ) ) : if not ip_address : raise ValueError ( '``user`` or ``ip_address`` must be present.' ) kwargs [ 'user__isnull' ] = True kwargs [ 'ip_address' ] = ip_address else : kwargs [ 'user' ] = user use_cookies = ( self . field . allow_anonymous and self . field . use_cookies ) if use_cookies : cookie_name = 'vote-%d.%d.%s' % ( kwargs [ 'content_type' ] . pk , kwargs [ 'object_id' ] , kwargs [ 'key' ] [ : 6 ] , ) cookie = cookies . get ( cookie_name ) if cookie : kwargs [ 'cookie' ] = cookie else : kwargs [ 'cookie__isnull' ] = True try : rating = Vote . objects . get ( ** kwargs ) return rating . score except Vote . MultipleObjectsReturned : pass except Vote . DoesNotExist : pass return
get_rating_for_user(user, ip_address=None, cookie=None)
        
        Returns the rating for a user or anonymous IP.