<s> from flask . ext . admin . _compat import iteritems <EOL> from flask . ext . admin . model . form import InlineBaseFormAdmin <EOL> class EmbeddedForm ( InlineBaseFormAdmin ) : <EOL> def __init__ ( self , ** kwargs ) : <EOL> super ( EmbeddedForm , self ) . __init__ ( ** kwargs ) <EOL> self . _form_subdocuments = convert_subdocuments ( getattr ( self , '<STR_LIT>' , { } ) ) <EOL> def convert_subdocuments ( values ) : <EOL> result = { } <EOL> for name , p in iteritems ( values ) : <EOL> if isinstance ( p , dict ) : <EOL> result [ name ] = EmbeddedForm ( ** p ) <EOL> elif isinstance ( p , EmbeddedForm ) : <EOL> result [ name ] = p <EOL> else : <EOL> raise ValueError ( '<STR_LIT>' % type ( p ) ) <EOL> return result </s>
