Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine: KindError - No implementation for kind 'ObjectName'

I'm writing a db.Model class in google app engine that looks something like this:

class Cheese(db.Model):
   name = db.StringProperty()
   def say_cheese(self):
      return name + "cheese"

For some reason, whenever I run:

cheese = Cheese(name = "smelly")
print thing.say_cheese()

I get a KindError - No implementation for kind 'Cheese'. I want it to say: "smelly cheese"

Am I doing something wrong? Am I not allowed to add a method to a db.Model object?

like image 301
Petwoip Avatar asked Dec 29 '22 10:12

Petwoip


1 Answers

It sounds like thing is actually being loaded from a db.ReferenceProperty() field (on a non-Cheese entity) which happens to be referring to a Cheese entity. If you access such a property without first importing the Cheese model then the code won't be able to find the Cheese kind to construct the entity and will fail with the error you indicated.

Anyway, try importing the Cheese model in the code which is causing the error. Then the code should be able to find the implementation for Cheese when it needs it.

To answer the other part of your question: Yes, you are certainly allowed to add your own methods to a db.Model subclass.

like image 161
David Underhill Avatar answered Jan 13 '23 13:01

David Underhill