Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8670)

Unified Diff: chrome/common/extensions/docs/server2/appengine_wrappers.py

Issue 10823105: Extensions Docs Server: Preview server and more integration tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: previewserver -> preview + fixes Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/handler.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/handler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698