title: SqlAlchemy No such polymorphic identity is defined
body: <p>I am trying to store user oauth details of 3rd party sites, BaseConnection table is used to store basic information of the connection</p>
  
  <pre><code>class BaseConnection(Base):
      __tablename__ = "BaseConnection"
      id = Column(Integer, primary_key=True)
      username = Column(Unicode(255),
                        ForeignKey('users.username'))
      type = Column(Unicode(255))
      is_active = Column(Boolean, default=False)
      last_connection = Column(DateTime, onupdate=datetime.utcnow)
  
      __mapper_args__ = {
          'polymorphic_identity': 'BaseConnection',
          'polymorphic_on': type
      }
  
      def __init__(self, username, type, is_active):
          self.username = username
          self.type = type
          self.is_active = is_active
  </code></pre>
  
  <p>Twitter connection is used to store ouath details of twitter account</p>
  
  <pre><code>class TwitterConnection(Base):
      __tablename__ = "TwitterConnection"
  
      connection_id = Column(Integer, ForeignKey('BaseConnection.id'),
                             primary_key=True)
      uid = Column(Unicode(255))
      access_key = Column(Unicode(255))
      access_secret = Column(Unicode(255))
      twitter_username = Column(Unicode(255))
      refresh_date = Column(DateTime)
  
      __mapper_args__ = {
          'polymorphic_identity': 'TwitterConnection'
      }
  
      def __init__(self, connection_id, 
                   uid, access_key, access_secret, twitter_username):
          self.connection_id = connection_id
          self.uid = uid
          self.access_key = access_key
          self.access_secret = access_secret
          self.twitter_username = twitter_username
          self.refresh_date = datetime.now()
  </code></pre>
  
  <p>Then I added first details to the table using the code </p>
  
  <pre><code>base_connection = BaseConnection('admin', TwitterConnection.__name__, True)
  base_connection.last_connection = datetime.now()
  DBSession.add(base_connection)
  DBSession.flush()
  tconnection = TwitterConnection(
                   base_connection.id,
                   uid=u'1234',
                   access_key=u'dummy',
                   access_secret=u'dummy',
                   twitter_username='dummy')
  DBSession.add(tconnection)
  DBSession.flush()
  transaction.commit()
  </code></pre>
  
  <p>I'm trying to write a query to find out all the 3rd party accounts of the user with specific username </p>
  
  <pre><code>qry = BaseConnection.query.filter(
                  BaseConnection.username==username)
  qry.all()
  </code></pre>
  
  <p>The above query is giving the error </p>
  
  <pre><code>`AssertionError: No such polymorphic_identity u'TwitterConnection' is defined
  </code></pre>
  
  <p>I am new to sqlalchemy, help is appreciated, Thank You.</p>