Yes of course!
 :) Thank you for the help.

Saved me a lot of sweat.

2009/1/16 Qian Qiao <qian.q...@gmail.com>:
>
> On Sat, Jan 17, 2009 at 02:02, Elliott Rosenthal
> <elliott.rosent...@gmail.com> wrote:
>>
>> Thank you for the help so far, it really has been useful.
>> If there any way you could give me a quick snippet of code to show me
>> how to build a factory method?
>
> 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
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to