#NEWLINE# def serialize( m , is_result = False ) : #NEWLINE# #INDENT# if ( m is None ) : #NEWLINE# #INDENT# return 'null' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( m , ( tuple , list ) ) : #NEWLINE# #INDENT# return ( '[ %s ]' % ', ' . join ( [ ( '%s' % serialize ( item ) ) for item in m ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( m , dict ) : #NEWLINE# #INDENT# return ( '{ %s }' % ', ' . join ( [ ( '%s: %s' % ( serialize ( key ) , serialize ( value ) ) ) for ( key , value ) in m . items ( ) ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( m , SafeData ) : #NEWLINE# #INDENT# return ( 'djang10.mark_safe(%s)' % serialize ( str ( m ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( m , HackDatetime ) : #NEWLINE# #INDENT# secs = ( ( m . delta . days * 3600 ) * 24 ) #NEWLINE# secs += m . delta . seconds #NEWLINE# return ( 'from_now(%d)' % secs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( m , basestring ) : #NEWLINE# #INDENT# if is_result : #NEWLINE# #INDENT# encoding = ( 'unicode_escape' if isinstance ( m , unicode ) else 'string_escape' ) #NEWLINE# m = m . encode ( encoding ) . replace ( '"' , '\\"' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# m = escape_str ( m ) #NEWLINE# #UNINDENT# m = ( '"%s"' % m ) #NEWLINE# if isinstance ( m , unicode ) : #NEWLINE# #INDENT# m = m . encode ( 'utf-8' ) #NEWLINE# #UNINDENT# return m #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( m , ( int , long ) ) : #NEWLINE# #INDENT# return ( '%d' % m ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( m , float ) : #NEWLINE# #INDENT# return ( '%f' % m ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( m , type ) : #NEWLINE# #INDENT# if ( m in exported_classes ) : #NEWLINE# #INDENT# return m . __name__ #NEWLINE# #UNINDENT# raise Exception ( ( "can't serialize the type: %s" % m ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( m , object ) : #NEWLINE# #INDENT# if isinstance ( m , HackTemplate ) : #NEWLINE# #INDENT# return ( 'new %s(%s)' % ( m . __class__ . __name__ , serialize ( m . template_string ) ) ) #NEWLINE# #UNINDENT# if ( m . __class__ in exported_classes ) : #NEWLINE# #INDENT# return ( 'new %s()' % m . __class__ . __name__ ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( ( "Can't serialize the obj: %s" % m . __class__ ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( ( "can't serialize the model: %s" % m ) )