mehulkar
mehulkar

Reputation: 4964

Querying with ndb.ComputedProperty

My computer property is defined like this:

class User(app.Model)
  DEFAULT_GPLUS_IMG_URL == "http://someimage.com/image/image.png"

  has_avatar = ndb.ComputedProperty(
    lambda self: True if self.avatar == DEFAULT_GPLUS_IMG_URL else False)

  @property
  def avatar(self):
    return self.gplus_data.get('image')

I am attempting to query like this in Interactive Console:

from google.appengine.ext import ndb
from app.lib.users import User

print User.query(User.has_avatar==True).fetch()

This returns an [].

But when I loop through the User.query() like this:

for i in User.query():
  print i.has_avatar

I get [True, False].

What am I doing wrong?

Upvotes: 1

Views: 491

Answers (1)

mehulkar
mehulkar

Reputation: 4964

As Guido pointed out in the comments to the question, the issue was related to dev_appserver cacheing. I was able to get the correct results the next day.

Upvotes: 1

Related Questions