python - Google App Engine: Implementing a collection of ordered lists -



python - Google App Engine: Implementing a collection of ordered lists -

i want implement simple hi-score service in app engine. here 2 model classes:

class hiscore(db.model): time = db.datetimeproperty() playername = db.stringproperty() score = db.integerproperty() class hiscoretable(db.model): countrycode = db.stringproperty() scores = db.listproperty(???)

question 1: how utilize 'listproperty'? it's hard find examples.

question 2: there way ensure hiscoretables ordered 'score' property of each fellow member score? , can automatically limit list to, say, 100 entries?

many thanks,

reuben

the listproperty list of python objects, plain , simple. if understand question correctly describing list of hiscores within hiscoretable

scores = db.listproperty(hiscore)

for sorting have utilize sorted sort list score before writing hiscoretable entity. doing equivalent of pickling whatever hiscore objects add together list, , retrieving same pickled version on subsequent queries. list of snapshots of previous hiscore rankings states, not current state. if intention cache scores period of time work - might consider using memcache instead.

alternately, in order reference actual hiscore entities this

scores = db.listproperty(db.key)

and retrieve hiscore's keys. 1 time again want utilize sorted sort list before writing store snapshot of rankings when hiscoretable written.

but if require absolutely date score-tables per country have query hiscore model straight every time.

query.filter('countrycode =', somecode).order('-score').fetch(limit=100)

python google-app-engine

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -