#NEWLINE# def document_to_dict( instance , properties = None , exclude = None ) : #NEWLINE# #INDENT# "\n    Returns a dict containing the data in ``instance`` suitable for passing as\n    a Form's ``initial`` keyword argument.\n\n    ``properties`` is an optional list of properties names. If provided, \n    only the named properties will be included in the returned dict.\n\n    ``exclude`` is an optional list of properties names. If provided, the named\n    properties will be excluded from the returned dict, even if they are listed \n    in the ``properties`` argument.\n    " #NEWLINE# data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for prop_name in instance . _doc . keys ( ) : #NEWLINE# #INDENT# if ( properties and ( not ( prop_name in properties ) ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( exclude and ( prop_name in exclude ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# data [ prop_name ] = instance [ prop_name ] #NEWLINE# #UNINDENT# return data