def _add_attribute(cls, key, value):
 if ('__mapper__' in cls.__dict__):
  if isinstance(value, Column):
   _undefer_column_name(key, value)
   cls.__table__.append_column(value)
   cls.__mapper__.add_property(key, value)
  elif isinstance(value, ColumnProperty):
   for col in value.columns:
    if (isinstance(col, Column) and (col.table is None)):
     _undefer_column_name(key, col)
     cls.__table__.append_column(col)
   cls.__mapper__.add_property(key, value)
  elif isinstance(value, MapperProperty):
   cls.__mapper__.add_property(key, clsregistry._deferred_relationship(cls, value))
  elif (isinstance(value, QueryableAttribute) and (value.key != key)):
   value = synonym(value.key)
   cls.__mapper__.add_property(key, clsregistry._deferred_relationship(cls, value))
  else:
   type.__setattr__(cls, key, value)
 else:
  type.__setattr__(cls, key, value)

def _add_attribute ( cls , key , value ) : if ( '__mapper__' in cls . __dict__ ) : if isinstance ( value , Column ) : _undefer_column_name ( key , value ) cls . __table__ . append_column ( value ) cls . __mapper__ . add_property ( key , value ) elif isinstance ( value , ColumnProperty ) : for col in value . columns : if ( isinstance ( col , Column ) and ( col . table is None ) ) : _undefer_column_name ( key , col ) cls . __table__ . append_column ( col ) cls . __mapper__ . add_property ( key , value ) elif isinstance ( value , MapperProperty ) : cls . __mapper__ . add_property ( key , clsregistry . _deferred_relationship ( cls , value ) ) elif ( isinstance ( value , QueryableAttribute ) and ( value . key != key ) ) : value = synonym ( value . key ) cls . __mapper__ . add_property ( key , clsregistry . _deferred_relationship ( cls , value ) ) else : type . __setattr__ ( cls , key , value ) else : type . __setattr__ ( cls , key , value )
add an attribute to an existing declarative class .