I have a simple app engine app that offers a download. I catch the
download request and record the time of the download in the data store
before sending the file. I'd also like to keep track of the total
number of downloads. Obviously, the number of rows in the data store
represents the total number of downloads.
However, looking at the API, the count() method of Query return a
maximum of 1000. This won't work because my number will grow much
larger than that.
So as a fix I added a count field to my data model so that the count
is updated upon every request. It looks something like this:
class Counter(db.Model):
count = db.IntegerProperty()
date = db.DateTimeProperty(auto_now_add=True)
class DownloadHandler(webapp.RequestHandler):
def get(self):
query = Counter.all()
query.order("-count")
counter = query.fetch(1)
count = counter[0].count
counter = Counter()
counter.count = count + 1
counter.put()
This works, but I'm seeing quite a few timeout errors in the logs.
So, what am I missing? Is there a better way to keep track of a
counter? I'd prefer to make the counter persistent and not simply a
member of the class as that seems volatile and likely to reset (say,
on a redeploy).
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---