def table_dictize(obj, context, **kw):
 result_dict = {}
 model = context['model']
 session = model.Session
 if isinstance(obj, RowProxy):
  fields = obj.keys()
 else:
  ModelClass = obj.__class__
  table = class_mapper(ModelClass).mapped_table
  fields = [field.name for field in table.c]
 for field in fields:
  name = field
  if (name in ('current', 'expired_timestamp', 'expired_id')):
   continue
  if (name == 'continuity_id'):
   continue
  value = getattr(obj, name)
  if (value is None):
   result_dict[name] = value
  elif isinstance(value, dict):
   result_dict[name] = value
  elif isinstance(value, int):
   result_dict[name] = value
  elif isinstance(value, long):
   result_dict[name] = value
  elif isinstance(value, datetime.datetime):
   result_dict[name] = value.isoformat()
  elif isinstance(value, list):
   result_dict[name] = value
  else:
   result_dict[name] = unicode(value)
 result_dict.update(kw)
 context['metadata_modified'] = max(result_dict.get('revision_timestamp', ''), context.get('metadata_modified', ''))
 return result_dict

def table_dictize ( obj , context , ** kw ) : result_dict = { } model = context [ 'model' ] session = model . Session if isinstance ( obj , RowProxy ) : fields = obj . keys ( ) else : ModelClass = obj . __class__ table = class_mapper ( ModelClass ) . mapped_table fields = [ field . name for field in table . c ] for field in fields : name = field if ( name in ( 'current' , 'expired_timestamp' , 'expired_id' ) ) : continue if ( name == 'continuity_id' ) : continue value = getattr ( obj , name ) if ( value is None ) : result_dict [ name ] = value elif isinstance ( value , dict ) : result_dict [ name ] = value elif isinstance ( value , int ) : result_dict [ name ] = value elif isinstance ( value , long ) : result_dict [ name ] = value elif isinstance ( value , datetime . datetime ) : result_dict [ name ] = value . isoformat ( ) elif isinstance ( value , list ) : result_dict [ name ] = value else : result_dict [ name ] = unicode ( value ) result_dict . update ( kw ) context [ 'metadata_modified' ] = max ( result_dict . get ( 'revision_timestamp' , '' ) , context . get ( 'metadata_modified' , '' ) ) return result_dict
get any model object and represent it as a dict .