Also, would it be a good idea to encapsulate a players picks for a week into a single structure? I'm just thinking out loud, but to see a particular player's picks, you have to do multiple lookups from the picks table.
Brent's Response:
player picks in one place:
The way I implemented the week data class might encapsulate each player's picks in one place. When it is loaded the value is retrieved from the memcache.
It currently looks like this:
class WeekData:
week = None
games = None
player_picks = None
picks = None
teams = None
players = None
The player_picks variable is a dictionary. The key is the player key and the value is a list of all the player's picks for that week. This dictionary is kept in the memcache so it would only need to read the database 1 time once all the picks are made.
The "picks" variable is similar but the key is the Pick datastore key value and the result in the Pick datastore object. So far I have not used the picks variable for anything so it might be deleted unless we find a use for it.
feedback
Do you think this satisfies the requirement of keeping all the picks by player in one place (one variable in memcache)?
Or do you think that this should be added to the datastore models somehow?
Maybe something like this?
class WeekPicks(db.Model):
week = db.StringProperty(required=True) # key to the Week class
player = db.StringProperty(required=True) # key to the Player class
picks = db.ListProperty(db.Key) # list of keys to the Pick class
From Byron:
Also, would it be a good idea to encapsulate a players picks for a week into a single structure? I'm just thinking out loud, but to see a particular player's picks, you have to do multiple lookups from the picks table.
Brent's Response:
player picks in one place:
The way I implemented the week data class might encapsulate each player's picks in one place. When it is loaded the value is retrieved from the memcache.
It currently looks like this:
The player_picks variable is a dictionary. The key is the player key and the value is a list of all the player's picks for that week. This dictionary is kept in the memcache so it would only need to read the database 1 time once all the picks are made.
Example:
picks variable not used
The "picks" variable is similar but the key is the Pick datastore key value and the result in the Pick datastore object. So far I have not used the picks variable for anything so it might be deleted unless we find a use for it.
feedback
Do you think this satisfies the requirement of keeping all the picks by player in one place (one variable in memcache)? Or do you think that this should be added to the datastore models somehow?
Maybe something like this?