def model_fields(model, only=None, exclude=None, field_args=None, converter=None):
 converter = (converter or ModelConverter())
 field_args = (field_args or {})
 props = model._properties
 field_names = list((x[0] for x in sorted(props.items(), key=(lambda x: x[1]._creation_counter))))
 if only:
  field_names = list((f for f in only if (f in field_names)))
 elif exclude:
  field_names = list((f for f in field_names if (f not in exclude)))
 field_dict = {}
 for name in field_names:
  field = converter.convert(model, props[name], field_args.get(name))
  if (field is not None):
   field_dict[name] = field
 return field_dict

def model_fields ( model , only = None , exclude = None , field_args = None , converter = None ) : converter = ( converter or ModelConverter ( ) ) field_args = ( field_args or { } ) props = model . _properties field_names = list ( ( x [ 0 ] for x in sorted ( props . items ( ) , key = ( lambda x : x [ 1 ] . _creation_counter ) ) ) ) if only : field_names = list ( ( f for f in only if ( f in field_names ) ) ) elif exclude : field_names = list ( ( f for f in field_names if ( f not in exclude ) ) ) field_dict = { } for name in field_names : field = converter . convert ( model , props [ name ] , field_args . get ( name ) ) if ( field is not None ) : field_dict [ name ] = field return field_dict
extracts and returns a dictionary of form fields for a given db .