def primary_key_value(instance, as_string=False):
 result = getattr(instance, primary_key_for(instance))
 if (not as_string):
  return result
 try:
  return str(result)
 except UnicodeEncodeError:
  return url_quote_plus(result.encode('utf-8'))

def primary_key_value ( instance , as_string = False ) : result = getattr ( instance , primary_key_for ( instance ) ) if ( not as_string ) : return result try : return str ( result ) except UnicodeEncodeError : return url_quote_plus ( result . encode ( 'utf-8' ) )
returns the value of the primary key field of the specified instance of a sqlalchemy model .