#NEWLINE# def unjelly( self , obj ) : #NEWLINE# #INDENT# if ( type ( obj ) is not types . ListType ) : #NEWLINE# #INDENT# return obj #NEWLINE# #UNINDENT# jelType = obj [ 0 ] #NEWLINE# if ( not self . taster . isTypeAllowed ( jelType ) ) : #NEWLINE# #INDENT# raise InsecureJelly ( jelType ) #NEWLINE# #UNINDENT# regClass = unjellyableRegistry . get ( jelType ) #NEWLINE# if ( regClass is not None ) : #NEWLINE# #INDENT# if isinstance ( regClass , ClassType ) : #NEWLINE# #INDENT# inst = _Dummy ( ) #NEWLINE# inst . __class__ = regClass #NEWLINE# method = inst . unjellyFor #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( regClass , type ) : #NEWLINE# #INDENT# inst = regClass . __new__ ( regClass ) #NEWLINE# method = inst . unjellyFor #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# method = regClass #NEWLINE# #UNINDENT# #UNINDENT# val = method ( self , obj ) #NEWLINE# if hasattr ( val , 'postUnjelly' ) : #NEWLINE# #INDENT# self . postCallbacks . append ( inst . postUnjelly ) #NEWLINE# #UNINDENT# return val #NEWLINE# #UNINDENT# regFactory = unjellyableFactoryRegistry . get ( jelType ) #NEWLINE# if ( regFactory is not None ) : #NEWLINE# #INDENT# state = self . unjelly ( obj [ 1 ] ) #NEWLINE# inst = regFactory ( state ) #NEWLINE# if hasattr ( inst , 'postUnjelly' ) : #NEWLINE# #INDENT# self . postCallbacks . append ( inst . postUnjelly ) #NEWLINE# #UNINDENT# return inst #NEWLINE# #UNINDENT# thunk = getattr ( self , ( '_unjelly_%s' % jelType ) , None ) #NEWLINE# if ( thunk is not None ) : #NEWLINE# #INDENT# ret = thunk ( obj [ 1 : ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# nameSplit = jelType . split ( '.' ) #NEWLINE# modName = '.' . join ( nameSplit [ : ( - 1 ) ] ) #NEWLINE# if ( not self . taster . isModuleAllowed ( modName ) ) : #NEWLINE# #INDENT# raise InsecureJelly ( ( 'Module %s not allowed (in type %s).' % ( modName , jelType ) ) ) #NEWLINE# #UNINDENT# clz = namedObject ( jelType ) #NEWLINE# if ( not self . taster . isClassAllowed ( clz ) ) : #NEWLINE# #INDENT# raise InsecureJelly ( ( 'Class %s not allowed.' % jelType ) ) #NEWLINE# #UNINDENT# if hasattr ( clz , '__setstate__' ) : #NEWLINE# #INDENT# ret = _newInstance ( clz ) #NEWLINE# state = self . unjelly ( obj [ 1 ] ) #NEWLINE# ret . __setstate__ ( state ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# state = self . unjelly ( jelType [ 1 ] ) #NEWLINE# ret = _newInstance ( clz , state ) #NEWLINE# #UNINDENT# if hasattr ( clz , 'postUnjelly' ) : #NEWLINE# #INDENT# self . postCallbacks . append ( ret . postUnjelly ) #NEWLINE# #UNINDENT# #UNINDENT# return ret