title: sqlalchemy, mixins, foreignkeys and declared_attr
body: <p>I know that I need to @declared_attr when declaring columns with foreign keys on declarative mixin classes, however I would like to know the reason behind this. </p>
  
  <p>thank you :)</p>
  
  <pre><code>#store traces
  class ListContainer():
          id = Column(Integer, primary_key=True)
          # timestamp = Column(DateTime, default=datetime.now())
          name = Column(String)
  #endclass
  
  #store flow in traces
  def list_item(tablename):
          class ListItem():
  #               @declared_attr
  #               def trace_id(cls):
  #                       return Column(Integer, ForeignKey(tablename+'.id'))
                  trace_id = Column(Integer, ForeignKey(tablename+'.id'))
                  id = Column(Integer, primary_key=True)
                  item_pos = Column(Integer)
                  # start_ea = Column(BLOB)
                  # end_ea = Column(BLOB)
          #endclass
          return ListItem
  </code></pre>