Reputation: 125
I'm currently trying to use ComputedProperties to obtain the length of the my key name which is a collection of letters from example xyz using the below code.
ndb.ComputedProperty(lambda e: len(e.get_by_id))
The issue I'm having is I cant seem to find a way of access the key within the model to get its length and then define this as a Computer Property.
I thought of storing the key as a string within the model but that duplicates things for no good reason.
Upvotes: 0
Views: 41
Reputation: 11360
How about an @property
?:
@property
def key_length(self):
return len( self.key.string_id() )
or lambda:
ndb.ComputedProperty( lambda self: len( self.key.string_id() ) )
This solves the question
Upvotes: 1