You don't generally need to touch the __init__ function of your
models, You use them like this:
class Auction(db.Model):
title = db.StringProperty()
description = db.StringProperty()
Then when you need your aution model, you just do:
auction = Auction(title="Title", description="description")
HTH.
-- Joe
http://code.google.com/appengine/docs/python/gettingstarted/usingdatastore.html
you see that you don't write an __init__() method if you subclass from
db.Model or db.Expando.
db.Model.__init__() will take care of assigning the correct attributes.
Define a factory method that builds the model?
-- Joe
Let's say we have a model that models a circle, and you were to
calculate the area of the circle in your __init__ method, we can use
the following as an alternative:
class Circle(db.Model):
centre = db.GeoPtProperty()
radius = db.IntegerProperty()
area = db.FloatProperty()
@staticmethod
def build_circle(centre, radius):
area = math.pi * radius * radius # example of the complex calculation
return Circle(centre = centre, radius = radius, area = area)
So when you need a circle somewhere in you code, instead of creating
it like circle = Circle(centre, radius), you do it as: circle =
Circle.build_circle(centre, radius)
HTH
-- Joe