Question

I have a simple Python program that uses GAE, and I am using GAE's memcache module to make sure that I do not screw up when updating the cache:

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)

Now this code should run without problem, but instead when I use the method post, it blows up:

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 -

This makes no sense at all, specially because I know that memcache has a method called gets(key):

Based on my research on stackoverflow I found this discussion:

And so I have flushed my cache and deleted all my local DB's content, but I am still getting the error.

What am I doing wrong?

Was it helpful?

Solution

You're mistaken: the memcache module does not have a gets function. See the documentation.

gets is a method of the memcache Client object: again, see the docs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top