> class Auction(db.Model):
>
>     title = db.StringProperty()
>     description = db.StringProperty()
>
>      def __init__(self, title, desc):
>           self.title = title
>           self.desc = desc
>
> This code is trimmed down from the full version, could you tell me if
> im doing anything fundamentally wrong with the __init__ function.

Yes, you are doing something fundamentally wrong.  If you define an
__init__ function, db.Model's __init__ won't be called unless you call
it and things won't work if db.Model's __init__ isn't called.

Instead, you want something like

      def __init__(self, *args, **kwds):
           {your code}
           super(Auction, self).__init__(*args, **kwds)
           {more of your code}

For example, {your code} could include "kwds.setdefault("title",
"default title")"  (Yes, this is the dumb/wrong way to do default
values.)

If you have named arguments, make sure that you pass the right
information to the super's __init__.

Note also that your __init__ will be called when the runtime
constructs an Auction, as it does for query and get results.

FWIW, it's likely that you shouldn't be writing your own __init__
function.




On Jan 16, 8:02 am, eli <elliott.rosent...@gmail.com> wrote:
> Hi,
>
> I cant complete something seemingly very simple.
> I simply want to create the following object (Auction)
>
> auction =Auction(title, desc)
>
> class Auction(db.Model):
>
>     title = db.StringProperty()
>     description = db.StringProperty()
>
>      def __init__(self, title, desc):
>           self.title = title
>           self.desc = desc
>
> This code is trimmed down from the full version, could you tell me if
> im doing anything fundamentally wrong with the __init__ function.
>
> Thank you for your time,
>
> Elliott
>
> App Engine reports:
> AttributeError: 'Auction' object has no attribute '_entity'
--~--~---------~--~----~------------~-------~--~----~
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