Dear all,

Given the following business context (one season has several games) :

seasons_table = Table('SEASONS', metadata,
                      Column('id', Integer, primary_key=True,
nullable=False))

games_table = Table('GAMES', metadata,
                          Column('id', Integer, primary_key=True,
nullable=False),
                          .....
                          Column('season_id', Integer,
ForeignKey('SEASONS.id'), nullable=False),
                          )

mapper(Season, seasons_table, properties={
    "games": dynamic_loader(Game, backref="season")
})

I'm wondering how to deal with these 2 use cases :

*Use case 1*

The user requests some information regarding season X.
I'd like to display the list of the games with their "index" : game 1, game
2... of the *current *season. Of course this is not the technical id but
rather some functional index.

That's easy to implement with *enumerate(season.games)* I guess.

*Use case 2

*The user requests some information regarding one specific game (let's say
by its technical ID).
I'd like to display the same "functional index" i.e. automatically populate
the "position in season" field.
Of course I could add a field in the database but it would require
synchronization when deleting a game, etc.

Do I have to loop through all the games of the current season to determine
my "relative position" or do you think there might be a better way ?

Thanks a lot !
Franck

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to