def get_unique(content_type, object_pk, name=None, request=None, ip=None, user_agent=None, user=None):
 if request:
  if request.user.is_authenticated():
   user = request.user
   ip = user_agent = None
  else:
   user = None
   ip = request.META.get('REMOTE_ADDR', '')
   user_agent = request.META.get('HTTP_USER_AGENT', '')[:255]
 hash_text = '\n'.join((unicode(x).encode('utf-8') for x in (content_type.pk, object_pk, (name or ''), ip, user_agent, ((user and user.pk) or 'None'))))
 unique_hash = hashlib.md5(hash_text).hexdigest()
 return (user, ip, user_agent, unique_hash)

def get_unique ( content_type , object_pk , name = None , request = None , ip = None , user_agent = None , user = None ) : if request : if request . user . is_authenticated ( ) : user = request . user ip = user_agent = None else : user = None ip = request . META . get ( 'REMOTE_ADDR' , '' ) user_agent = request . META . get ( 'HTTP_USER_AGENT' , '' ) [ : 255 ] hash_text = '\n' . join ( ( unicode ( x ) . encode ( 'utf-8' ) for x in ( content_type . pk , object_pk , ( name or '' ) , ip , user_agent , ( ( user and user . pk ) or 'None' ) ) ) ) unique_hash = hashlib . md5 ( hash_text ) . hexdigest ( ) return ( user , ip , user_agent , unique_hash )
extract a set of unique identifiers from the request .