def _key_string(key, key_prefix='', server_to_user_dict=None):
 if _is_pair(key):
  key = key[1]
 if (not isinstance(key, basestring)):
  raise TypeError(('Key must be a string instance, received %r' % key))
 if (not isinstance(key_prefix, basestring)):
  raise TypeError(('key_prefix must be a string instance, received %r' % key_prefix))
 server_key = (key_prefix + key)
 if isinstance(server_key, unicode):
  server_key = server_key.encode('utf-8')
 if (len(server_key) > MAX_KEY_SIZE):
  server_key = hashlib.sha1(server_key).hexdigest()
 if (server_to_user_dict is not None):
  assert isinstance(server_to_user_dict, dict)
  server_to_user_dict[server_key] = key
 return server_key

def _key_string ( key , key_prefix = '' , server_to_user_dict = None ) : if _is_pair ( key ) : key = key [ 1 ] if ( not isinstance ( key , basestring ) ) : raise TypeError ( ( 'Key must be a string instance, received %r' % key ) ) if ( not isinstance ( key_prefix , basestring ) ) : raise TypeError ( ( 'key_prefix must be a string instance, received %r' % key_prefix ) ) server_key = ( key_prefix + key ) if isinstance ( server_key , unicode ) : server_key = server_key . encode ( 'utf-8' ) if ( len ( server_key ) > MAX_KEY_SIZE ) : server_key = hashlib . sha1 ( server_key ) . hexdigest ( ) if ( server_to_user_dict is not None ) : assert isinstance ( server_to_user_dict , dict ) server_to_user_dict [ server_key ] = key return server_key
utility function to handle different ways of requesting keys .