Python 属性错误:';模块';对象没有属性';获取';memcache GAE
我有一个使用GAE的简单Python程序,我正在使用GAE的memcache模块来确保在更新缓存时不会出错:Python 属性错误:';模块';对象没有属性';获取';memcache GAE,python,google-app-engine,caching,memcached,Python,Google App Engine,Caching,Memcached,我有一个使用GAE的简单Python程序,我正在使用GAE的memcache模块来确保在更新缓存时不会出错: from google.appengine.api import memcache class NewPost(BlogHandler): def get(self): self.render("newpost.html") def post(self): #update cache for the front page
from google.appengine.api import memcache
class NewPost(BlogHandler):
def get(self):
self.render("newpost.html")
def post(self):
#update cache for the front page
val, unique = memcache.gets(FRONT_PAGE_KEY)
for p in val:
logging.warning(p)
现在,这段代码应该可以毫无问题地运行,但当我使用方法post时,它崩溃了:
Traceback (most recent call last):
File "/home/pedro/google_appengine/google/appengine/runtime/wsgi.py", line 266, in Handle
result = handler(dict(self._environ), self._StartResponse)
File "/home/pedro/google_appengine/lib/webapp2-2.3/webapp2.py", line 1519, in __call__
response = self._internal_error(e)
File "/home/pedro/google_appengine/lib/webapp2-2.3/webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "/home/pedro/google_appengine/lib/webapp2-2.3/webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "/home/pedro/google_appengine/lib/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "/home/pedro/google_appengine/lib/webapp2-2.3/webapp2.py", line 1077, in __call__
return handler.dispatch()
File "/home/pedro/google_appengine/lib/webapp2-2.3/webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "/home/pedro/google_appengine/lib/webapp2-2.3/webapp2.py", line 545, in dispatch
return method(*args, **kwargs)
File "/home/pedro/google_appengine/hw6/blog.py", line 172, in post
val, unique = memcache.gets(FRONT_PAGE_KEY)
AttributeError: 'module' object has no attribute 'gets'
INFO 2014-05-08 13:36:49,525 module.py:639] default: "POST /blog/newpost HTTP/1.1" 500 -
这毫无意义,特别是因为我知道memcache有一个名为get(key)
的方法:
我做错了什么?你搞错了:
memcache
模块没有get
功能。看
gets
是memcacheClient
对象的一种方法:再次请参见。您错了:memcache
模块没有gets
功能。看
get
是memcacheClient
对象的一种方法:再次请参见。您需要更仔细地检查文档;模块函数:,不同于客户端
类方法:您需要更仔细地检查文档;模块函数:,不同于客户机
类方法:好吧,你的答案引导我走上了一条最终解决问题的道路!如果你愿意的话,你能问一下这个链接到你的答案吗?它真的解释了一切,我也得到了一些例子!我会在等待选择答案的时间结束后立即选择!好吧,你的回答引导我走上了一条最终解决我问题的道路!如果你愿意的话,你能问一下这个链接到你的答案吗?它真的解释了一切,我也得到了一些例子!我会在等待选择答案的时间结束后立即选择!