| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 | 6 |
| 7 def GetAppVersion(): |
| 8 if 'CURRENT_VERSION_ID' in os.environ: |
| 9 return os.environ['CURRENT_VERSION_ID'] |
| 10 # Not running on appengine, get it from the app.yaml file ourselves. We |
| 11 # could properly parse this using a yaml library but Python doesn't have |
| 12 # one built in so whatevs. |
| 13 version_key = 'version:' |
| 14 app_yaml_path = os.path.join(os.path.split(__file__)[0], 'app.yaml') |
| 15 with open(app_yaml_path, 'r') as app_yaml: |
| 16 version_line = [line for line in app_yaml.read().split('\n') |
| 17 if line.startswith(version_key)][0] |
| 18 return version_line[len(version_key):].strip() |
| 19 |
| 7 def IsDevServer(): | 20 def IsDevServer(): |
| 8 return os.environ.get('SERVER_SOFTWARE', '').find('Development') == 0 | 21 return os.environ.get('SERVER_SOFTWARE', '').find('Development') == 0 |
| 9 | 22 |
| 10 # This will attempt to import the actual App Engine modules, and if it fails, | 23 # This will attempt to import the actual App Engine modules, and if it fails, |
| 11 # they will be replaced with fake modules. This is useful during testing. | 24 # they will be replaced with fake modules. This is useful during testing. |
| 12 try: | 25 try: |
| 13 import google.appengine.ext.blobstore as blobstore | 26 import google.appengine.ext.blobstore as blobstore |
| 14 from google.appengine.ext.blobstore.blobstore import BlobReferenceProperty | 27 from google.appengine.ext.blobstore.blobstore import BlobReferenceProperty |
| 15 import google.appengine.ext.db as db | 28 import google.appengine.ext.db as db |
| 16 import google.appengine.ext.webapp as webapp | 29 import google.appengine.ext.webapp as webapp |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 db._store.pop(key, None) | 257 db._store.pop(key, None) |
| 245 return _RPC() | 258 return _RPC() |
| 246 | 259 |
| 247 @staticmethod | 260 @staticmethod |
| 248 def put_async(value): | 261 def put_async(value): |
| 249 db._store[value.key] = value | 262 db._store[value.key] = value |
| 250 return _RPC() | 263 return _RPC() |
| 251 | 264 |
| 252 class BlobReferenceProperty(object): | 265 class BlobReferenceProperty(object): |
| 253 pass | 266 pass |
| OLD | NEW |