Index: chrome/common/extensions/docs/server2/appengine_wrappers.py |
diff --git a/chrome/common/extensions/docs/server2/appengine_wrappers.py b/chrome/common/extensions/docs/server2/appengine_wrappers.py |
index 67f6feb71a2446d426158bac16ea723e9a257c0b..7fcb7159d5dd3330c8715a3023751e6201369a44 100644 |
--- a/chrome/common/extensions/docs/server2/appengine_wrappers.py |
+++ b/chrome/common/extensions/docs/server2/appengine_wrappers.py |
@@ -2,9 +2,7 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
-from in_memory_memcache import InMemoryMemcache |
- |
-# This will attempt to import the actual Appengine modules, and if it fails, |
+# This will attempt to import the actual App Engine modules, and if it fails, |
# they will be replaced with fake modules. This is useful during testing. |
try: |
import google.appengine.ext.webapp as webapp |
@@ -12,6 +10,8 @@ try: |
import google.appengine.api.urlfetch as urlfetch |
except ImportError: |
class FakeUrlFetch(object): |
+ """A fake urlfetch module that errors for all method calls. |
+ """ |
def fetch(self, url): |
raise NotImplementedError() |
@@ -22,7 +22,26 @@ except ImportError: |
raise NotImplementedError() |
urlfetch = FakeUrlFetch() |
- # Use an in-memory memcache if Appengine memcache isn't available. |
+ class InMemoryMemcache(object): |
+ """A memcache that stores items in memory instead of using the memcache |
+ module. |
+ """ |
+ def __init__(self): |
+ self._cache = {} |
+ |
+ def set(self, key, value, namespace, time=60): |
+ if namespace not in self._cache: |
+ self._cache[namespace] = {} |
+ self._cache[namespace][key] = value |
+ |
+ def get(self, key, namespace): |
+ if namespace not in self._cache: |
+ return None |
+ return self._cache[namespace].get(key, None) |
+ |
+ def delete(self, key, namespace): |
+ if namespace in self._cache: |
+ self._cache[namespace].pop(key) |
memcache = InMemoryMemcache() |
# A fake webapp.RequestHandler class for Handler to extend. |
@@ -31,3 +50,6 @@ except ImportError: |
def __init__(self, request, response): |
self.request = request |
self.response = response |
+ |
+ def redirect(self, path): |
+ self.request.path = path |