#NEWLINE# def save( self , commit = True , dynamic = True ) : #NEWLINE# #INDENT# "\n        Saves this ``form``'s cleaned_data into document instance\n        ``self.instance``.\n\n        If commit=True, then the changes to ``instance`` will be saved to the\n        database. Returns ``instance``.\n        " #NEWLINE# opts = self . _meta #NEWLINE# cleaned_data = self . cleaned_data . copy ( ) #NEWLINE# for prop_name in self . instance . _doc . keys ( ) : #NEWLINE# #INDENT# if ( opts . properties and ( prop_name not in opts . properties ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( opts . exclude and ( prop_name in opts . exclude ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( prop_name in cleaned_data ) : #NEWLINE# #INDENT# value = cleaned_data . pop ( prop_name ) #NEWLINE# if ( value is not None ) : #NEWLINE# #INDENT# setattr ( self . instance , prop_name , dynamic ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if dynamic : #NEWLINE# #INDENT# for attr_name in cleaned_data . keys ( ) : #NEWLINE# #INDENT# if ( opts . exclude and ( attr_name in opts . exclude ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# value = cleaned_data [ attr_name ] #NEWLINE# if ( value is not None ) : #NEWLINE# #INDENT# setattr ( self . instance , attr_name , value ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if commit : #NEWLINE# #INDENT# self . instance . save ( ) #NEWLINE# #UNINDENT# return self . instance