我看到appengine的本地devserver在过滤查询时出现了一些奇怪的行为。在
我已经实现了这个碎片计数器。在
http://code.google.com/appengine/articles/sharding_counters.html
我看到的是:
调试之后,我注意到,应该与GeneralCounterShard实体匹配的查询与提供的名称不匹配。在
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
因此,当数据库中有GeneralCounterShard实体时,上面代码中的过滤器不匹配任何内容。在
我必须说,我对appengine和Python还是个新手,但我不明白为什么这一点会起作用,然后就不起作用了。实体仍在数据库中。在
这可能是某种缺陷还是我遗漏了什么?在
谢谢!在
在这个片段中:.filter('name=',name)我想您需要删除='后面的空格。在
相关问题 更多 >
编程相关推荐