All pastes #637363 Raw Edit

Anonymous

public text v1 · immutable
#637363 ·published 2007-07-28 20:46 UTC
rendered paste body
user_subscriptions_table = Table('user_subscriptions', metadata,
    Column('user_id', Integer, ForeignKey('tg_user.user_id'), index=True),
    Column('subscriber_id', Integer, ForeignKey('tg_user.user_id'), index=True),
    mysql_engine='InnoDB'
)

assign_mapper(session.context, User, users_table,
          properties={
              'subscribers':relation(User, secondary=user_subscriptions_table, 
                                     primaryjoin=user_subscriptions_table.c.user_id==users_table.c.user_id, 
                                     secondaryjoin=user_subscriptions_table.c.subscriber_id==users_table.c.user_id), 
              'subscribed':relation(User, secondary=user_subscriptions_table, 
                                     primaryjoin=user_subscriptions_table.c.subscriber_id==users_table.c.user_id, 
                                     secondaryjoin=user_subscriptions_table.c.user_id==users_table.c.user_id, viewonly=True),
}

Want to get list of Users in order of highest number of subscribers.