Y2H
Y2H

Reputation: 2537

How to pass instance ID as argument in property validator in Python?

I have an ndb.Model class and inside it there is a particular attribute that calls a certain function as validator:

class Article(ndb.Model):
    itemList = ndb.StringProperty()
    ...
    penInspc = ndb.IntegerProperty(default=0, indexed=True, validator=minPen)

I want the function minPen() to print the ID of the instance of class Article. How do I do that?

Upvotes: 0

Views: 84

Answers (1)

user5609829
user5609829

Reputation:

Just use a hook before put. This is as effective as a validator but also won’t mess up your queries in case you don’t have old data that do not respect the new validator rules.

Upvotes: 1

Related Questions