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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..67f6feb71a2446d426158bac16ea723e9a257c0b |
--- /dev/null |
+++ b/chrome/common/extensions/docs/server2/appengine_wrappers.py |
@@ -0,0 +1,33 @@ |
+# Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+# 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, |
not at google - send to devlin
2012/07/31 06:04:36
nit: (here an below), it's "App Engine" not "Appen
|
+# they will be replaced with fake modules. This is useful during testing. |
+try: |
+ import google.appengine.ext.webapp as webapp |
+ import google.appengine.api.memcache as memcache |
+ import google.appengine.api.urlfetch as urlfetch |
+except ImportError: |
+ class FakeUrlFetch(object): |
+ def fetch(self, url): |
+ raise NotImplementedError() |
+ |
+ def create_rpc(self): |
+ raise NotImplementedError() |
+ |
+ def make_fetch_call(self): |
+ raise NotImplementedError() |
+ urlfetch = FakeUrlFetch() |
+ |
+ # Use an in-memory memcache if Appengine memcache isn't available. |
+ memcache = InMemoryMemcache() |
+ |
+ # A fake webapp.RequestHandler class for Handler to extend. |
+ class webapp(object): |
+ class RequestHandler(object): |
+ def __init__(self, request, response): |
+ self.request = request |
+ self.response = response |