Quint
Quint

Reputation: 33

App Engine devserver Query filter not working

I'm seeing some strange behaviour with the local devserver of App Engine while filtering on a Query.

I've implemented this Sharded Counter.

http://code.google.com/appengine/articles/sharding_counters.html

And this is what i'm seeing:

  1. I increment the counter and the counter entity is successfully created and the count gets updated as it should.
  2. Immediatally after this When i call get_count(), it returns the count of the just created GeneralCounterShard Entity
  3. A moment later when i call getCount(), it returns nothing.

After debugging i notice that the query that should match the GeneralCounterShard Entity which i want the count for, does not match with the provided name.

def get_count(name):    
"""Retrieve the value for a given sharded counter.
Parameters:      name - The name of the counter    """
total = memcache.get(name)
if total is None:
    total = 0
    for counter in GeneralCounterShard.all().filter('name = ', name):
        total += counter.count
        memcache.add(name, total, 60)
return total

So the filter in the code above does not match anything while there are GeneralCounterShard entities with the supplied name in the database.

I must say i'm new to App Engine and Python but i don't understand why this works for a moment and then it doesn't anymore. The Entities are still in the database.

Could this be some sort of bug or am i missing something?

Thanks!

Upvotes: 1

Views: 299

Answers (1)

Guido van Rossum
Guido van Rossum

Reputation: 16890

In this fragment: .filter('name = ', name) I think you need to remove the space after the =.

Upvotes: 1

Related Questions