Reputation: 6389
I have this model:
class User(ndb.Model):
firstname = ndb.StringProperty(required = True)
lastname = ndb.StringProperty(required = True)
email = ndb.StringProperty(required = True)
birthday = ndb.DateProperty(required = True)
@classmethod
def to_message(self):
return UserMessage(firstname = self.firstname,
lastname = self.lastname,
email = self.email,
birthday_day = self.birthday.day)
Where UserMessage is a protoRPC object. And want something like this:
user = User.query(User.email == '[email protected]').get()
user_message = user.to_message()
Upvotes: 1
Views: 186
Reputation: 12986
You can't use a class method here.
There is no self
in a classmethod , by convention it is cls
and you are passed the class not an instance. to_message
should be a normal method.
Upvotes: 2