Just a note that there is a db.ComputedProperty included in the SDK. http://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/ext/db/__init__.py#3339
Works just like DerivedProperty. Robert On Wed, Mar 2, 2011 at 07:29, Nickolas Daskalou <n...@daskalou.com> wrote: > +1. Nick Johnson's DerivedProperty has proved invaluable during the course > of my development on App Engine. > Jon, in your example, this is how you could implement it using > DerivedProperty: > ---------------------- > from aetycoon import DerivedProperty > class Message(db.Model): > text= db.StringProperty(required=True) # text of the message > likes= db.StringListProperty() #usernames that liked the message > @DerivedProperty > def num_likes(self): > return self.likes and len(likes) or 0 > ---------------------- > Then to get the top 10 liked messages: > ---------------------- > messages = Message.all().order('-num_likes').fetch(10) > ---------------------- > Nick > > > On 2 March 2011 22:59, djidjadji <djidja...@gmail.com> wrote: >> >> You can use the DerivedProperty from the aetycoon lib written by Nick >> Johnson (search his blog). >> During a put it will update the property no need to perform the count >> yourself. >> >> 2011/3/1 ogterran <jonathanh...@gmail.com>: >> > Thanks guys. I'll add another IntegerProperty to increment the count >> >> -- >> 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. >> > > -- > 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. > -- 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.