Can someone help me understand how to access the results of a query?
This is my model:
class Rep(db.Model):
mAUTHOR = db.UserProperty(auto_current_user=True)
mUNIQUE = db.StringProperty()
mCOUNT = db.IntegerProperty()
mDATE = db.DateTimeProperty(auto_now=True)
mDATE0 = db.DateTimeProperty(auto_now_add=True)
mWEIGHT = db.IntegerProperty()
The app has a textarea form and user submits repetitions. mCOUNT is
the number of repetitions. I use this query to display top ten reps:
QUERY = Rep.all()
QUERY.filter("mAUTHOR =", user)
QUERY.order("-mCOUNT")
RESULTS = QUERY.fetch(10)
I display the results with Mako template:
% for result in RESULTS:
<p>${result.mUNIQUE} (${result.mCOUNT})</p>
% endfor
Instead of sorting by mCOUNT I want to sort by mWEIGHT so that an old
item with high count should be lower than a new item with lower count.
But the precise weighing formula is not important at this point. For
instance, it may be
mWEIGHT = mDATE * mCOUNT
What I do not understand is, how do I access mDATE and mCOUNT to put
them in the formula? I am having difficulty, in general, visualizing
the result of a query. The tutorial
http://code.google.com/appengine/docs/python/datastore/creatinggettinganddeletingdata.html#Getting_Entities_Using_a_Query
says that the query returns "the requested results as a list of model
instances." What is a "list of model instances?" And how to access
them as a variables in this context. Thanks for your help.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.