user2154587
user2154587

Reputation: 63

Assign a key name in pre put hook: inheritance from a general ndb model

I have this (working) model:

class WorkingModel(ndb.Model):
    # ...some properties...
    def _pre_put_hook(self):
        self.key = ndb.Key(WorkingModel, slugify(self.name))

What if I want to generalize the solution via inheritance? i.e.:

class slugModel(ndb.Model):
    def _pre_put_hook(self):
        self.key = ndb.Key(???, slugify(self.name))

class WorkingModel(slugModel):
    name = ndb.StringProperty()

Upvotes: 0

Views: 110

Answers (1)

TwistedSim
TwistedSim

Reputation: 2030

You can use self.__class__ as argument.

Upvotes: 1

Related Questions