I use this code to keep an id: class M(db.Model): id = db.IntegerProperty() time = db.DateTimeProperty(auto_now_add=True) @staticmethod def max_id(): maxID = memcache.get('MaxID') if maxID: return maxID messages = Message.all() messages.order("-id") message = messages.get() if message: return message.id else: return 0
entity = M() entity.id = M.maxID + 1 entity.put() 2009/4/19 David Wilson <david.wil...@entertainmentcloud.com> > > > thanks! i missed that in the docs :) > > I wasnt using a datetime just to save a bit of space, but i can see i > need to know to guarantee ordering, or if i want to do ordered paging > via key i would need to handle key creation myself to make sure they > are in order. > > This becomes harder in one case for me as users can create designs > that need to be paged through in creation order. There will be too > much contention on a glodal counter for this, so i guess an offset > page on date is the best i can do for now. Or just not worry when some > 'new designs' are out of order. > > > > On Apr 18, 2:20 am, David Symonds <dsymo...@gmail.com> wrote: > > On Sat, Apr 18, 2009 at 3:21 PM, David Wilson > > > > <david.wil...@entertainmentcloud.com> wrote: > > > Is this expected behaviour? and thus do i need to always give a > > > key_name to guarantee order? this creates scaling issues for order > > > counter (which is probably why its not in order in the backend :) ) > > > > Keys are only guaranteed to be unique, not sequential or in order: > > http://code.google.com/appengine/docs/python/datastore/keysandentityg. > .. > > > > What is wrong with giving your models a timestamp property (with > > auto_now_add=True), and sorting by that? > > > > Dave. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---