本文整理匯總了Python中google.appengine.api.memcache.get方法的典型用法代碼示例。如果您正苦於以下問題:Python memcache.get方法的具體用法?Python memcache.get怎麽用?Python memcache.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類google.appengine.api.memcache
的用法示例。
在下文中一共展示了memcache.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: CategoryTest
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def CategoryTest(request):
"""Loads the test frameset for a category."""
category = re.sub('\/test.*', '', request.path)[1:]
test_set = all_test_sets.GetTestSet(category)
testurl = ''
test_key = request.GET.get('test_key')
if test_key:
test = test_set.GetTest(test_key)
testurl = test.url
params = {
'category': test_set.category,
'page_title': '%s - Tests' % test_set.category_name,
'continue': request.GET.get('continue', ''),
'autorun': request.GET.get('autorun', ''),
'testurl': testurl,
'test_page': test_set.test_page
}
return Render(request, 'test_frameset.html', params)
示例2: CategoryTestDriver
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def CategoryTestDriver(request):
"""Loads the test driver for a category."""
category = request.GET.get('category')
test_set = all_test_sets.GetTestSet(category)
params = {
'category': test_set.category,
'category_name': test_set.category_name,
'page_title': '%s - Test Driver' % test_set.category_name,
'continue': request.GET.get('continue', ''),
'autorun': request.GET.get('autorun', ''),
'test_page': test_set.test_page,
'testurl': request.GET.get('testurl', ''),
'csrf_token': request.session.get('csrf_token'),
'hide_footer': True
}
return Render(request, TEST_DRIVER_TPL, params, category)
示例3: Home
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def Home(request):
"""Our Home page.
This also doubles as a general API request handler with a few specific
bits for the home page template."""
# The recent tests table.
recent_tests = memcache.get(key=RECENT_TESTS_MEMCACHE_KEY)
if not recent_tests:
ScheduleRecentTestsUpdate()
show_evolution = False
params = {
'page_title': 'Home',
'message': request.GET.get('message'),
'recent_tests': recent_tests,
'show_evolution': show_evolution,
}
return GetResults(request, template='home.html', params=params,
do_sparse_filter=True)
示例4: GvizTableData
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def GvizTableData(request):
"""Returns a string formatted for consumption by a Google Viz table."""
#def throw_deadline():
# logging.info('MANUAL THROW!! DeadlineExceededError DeadlineExceededError')
# raise DeadlineExceededError
#t = Timer(15.0, throw_deadline)
test_set = None
category = request.GET.get('category')
if not category:
return http.HttpResponseBadRequest('Must pass category=something')
test_set = all_test_sets.GetTestSet(category)
if not test_set:
return http.HttpResponseBadRequest(
'No test set was found for category=%s' % category)
formatted_gviz_table_data = GetStats(request, test_set, 'gviz_table_data')
return http.HttpResponse(formatted_gviz_table_data)
示例5: GetTestScoreAndDisplayValue
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def GetTestScoreAndDisplayValue(self, test_key, raw_scores):
"""Get a normalized score (0 to 100) and a value to output to the display.
Args:
test_key: a key for a test_set test.
raw_scores: a dict of raw_scores indexed by test keys.
Returns:
score, display_value
# score is from 0 to 100.
# display_value is the text for the cell.
"""
#logging.info('GetTestScoreAndDisplayValue, %s, %s' % (test_key, raw_scores))
score = 0
raw_score = raw_scores.get(test_key, None)
if raw_score is None:
raw_score = ''
if raw_score != '':
test = Test.get_test_from_category(self.category)
score = test.get_score_from_display(test_key, raw_score)
#logging.info('score: %s, display: %s', score, raw_score)
return score, raw_score
示例6: testBeacon
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def testBeacon(self):
csrf_token = self.client.get('/get_csrf').content
params = {
'category': self.test_set.category,
'results': 'apple=1,banana=2,coconut=4',
'csrf_token': csrf_token
}
response = self.client.get('/beacon', params, **mock_data.UNIT_TEST_UA)
self.assertEqual(204, response.status_code)
# Did a ResultParent get created?
query = db.Query(result.ResultParent)
query.filter('category =', self.test_set.category)
result_parent = query.get()
self.assertNotEqual(result_parent, None)
result_times = result_parent.GetResultTimes()
self.assertEqual(
[('apple', 1, False), ('banana', 2, False), ('coconut', 4, False)],
sorted((x.test, x.score, x.dirty) for x in result_times))
示例7: testCreated
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def testCreated(self):
created_base = datetime.datetime(2009, 9, 9, 9, 9, 0)
keys = []
for scores in ((0, 10, 100), (1, 20, 200)):
ip = '1.2.2.%s' % scores[1]
result = ResultParent.AddResult(
self.test_set, ip, mock_data.GetUserAgentString('Firefox 3.5'),
'apple=%s,banana=%s,coconut=%s' % scores,
created=created_base + datetime.timedelta(seconds=scores[1]))
keys.append(str(result.key()))
params = {
'model': 'ResultParent',
'created': created_base + datetime.timedelta(seconds=15),
}
response = self.client.get('/admin/data_dump_keys', params)
self.assertEqual(200, response.status_code)
response_params = simplejson.loads(response.content)
self.assertEqual(None, response_params['bookmark'])
self.assertEqual(keys[1:], response_params['keys'])
示例8: testBasic
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def testBasic(self):
self.mox.StubOutWithMock(
result_stats.CategoryBrowserManager, 'UpdateSummaryBrowsers')
categories = [ts.category for ts in all_test_sets.GetVisibleTestSets()]
# Use mox to make sure UpdateSummaryBrowsers gets called.
result_stats.CategoryBrowserManager.UpdateSummaryBrowsers(categories)
self.mox.ReplayAll()
params = {
'category': 'network',
'version_level': 0,
'browsers': 'IE,Firefox',
}
response = self.client.get('/admin/upload_category_browsers', params)
self.assertEqual('Success.', response.content)
self.assertEqual(200, response.status_code)
self.assertEqual(['Firefox', 'IE'], self.manager.GetBrowsers('network', 0))
self.mox.VerifyAll()
示例9: _get_memcache_value_and_type
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def _get_memcache_value_and_type(self, key):
"""Fetch value from memcache and detect its type.
Args:
key: String
Returns:
(value, type), value is a Python object or None if the key was not set in
the cache, type is a string describing the type of the value.
"""
try:
value = memcache.get(key)
except (pickle.UnpicklingError, AttributeError, EOFError, ImportError,
IndexError), e:
# Pickled data could be broken or the user might have stored custom class
# instances in the cache (which can't be unpickled from here).
msg = 'Failed to retrieve value from cache: %s' % e
return msg, 'error'
示例10: xsrf_secret_key
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def xsrf_secret_key():
"""Return the secret key for use for XSRF protection.
If the Site entity does not have a secret key, this method will also create
one and persist it.
Returns:
The secret key.
"""
secret = memcache.get(XSRF_MEMCACHE_ID, namespace=OAUTH2CLIENT_NAMESPACE)
if not secret:
# Load the one and only instance of SiteXsrfSecretKey.
model = SiteXsrfSecretKey.get_or_insert(key_name='site')
if not model.secret:
model.secret = _generate_new_xsrf_secret_key()
model.put()
secret = model.secret
memcache.add(XSRF_MEMCACHE_ID, secret, namespace=OAUTH2CLIENT_NAMESPACE)
return str(secret)
示例11: __init__
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def __init__(self, scope, **kwargs):
"""Constructor for AppAssertionCredentials
Args:
scope: string or iterable of strings, scope(s) of the credentials being
requested.
**kwargs: optional keyword args, including:
service_account_id: service account id of the application. If None or
unspecified, the default service account for the app is used.
"""
self.scope = util.scopes_to_string(scope)
self._kwargs = kwargs
self.service_account_id = kwargs.get('service_account_id', None)
# Assertion type is no longer used, but still in the parent class signature.
super(AppAssertionCredentials, self).__init__(None)
示例12: locked_get
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def locked_get(self):
"""Retrieve Credential from datastore.
Returns:
oauth2client.Credentials
"""
credentials = None
if self._cache:
json = self._cache.get(self._key_name)
if json:
credentials = Credentials.new_from_json(json)
if credentials is None:
entity = self._get_entity()
if entity is not None:
credentials = getattr(entity, self._property_name)
if self._cache:
self._cache.set(self._key_name, credentials.to_json())
if credentials and hasattr(credentials, 'set_store'):
credentials.set_store(self)
return credentials
示例13: oauth2decorator_from_clientsecrets
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def oauth2decorator_from_clientsecrets(filename, scope,
message=None, cache=None):
"""Creates an OAuth2Decorator populated from a clientsecrets file.
Args:
filename: string, File name of client secrets.
scope: string or list of strings, scope(s) of the credentials being
requested.
message: string, A friendly string to display to the user if the
clientsecrets file is missing or invalid. The message may contain HTML and
will be presented on the web interface for any method that uses the
decorator.
cache: An optional cache service client that implements get() and set()
methods. See clientsecrets.loadfile() for details.
Returns: An OAuth2Decorator
"""
return OAuth2DecoratorFromClientSecrets(filename, scope,
message=message, cache=cache)
示例14: updateAppStats
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def updateAppStats(data):
device = data.get('deviceinfo', {})
apps = dict((app['name'], app['version']) for app in data.get('applications', []) if 'name' in app and 'version' in app)
if 'name' in device and 'productcode' in device and 'deviceid' in device:
id = hashlib.sha1('camera_%s_%s_%s' % (device['name'], device['productcode'], device['deviceid'])).hexdigest()
camera = Camera.get_by_id(id)
isNewCamera = not camera
if not camera:
camera = Camera(id=id)
camera.model = device['name']
camera.apps, installed, updated = diffApps(camera.apps or {}, apps)
camera.put()
if isNewCamera:
CameraModelCounter.increment(camera.model)
for app in installed:
AppInstallCounter.increment(app)
for app in updated:
AppUpdateCounter.increment(app)
示例15: post
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import get [as 別名]
def post(self):
data = self.request.body
dataDict = marketserver.parsePostData(data)
taskKey = int(dataDict.get('session', {}).get('correlationid', 0))
task = ndb.Key(Task, taskKey).get()
if not task:
return self.error(404)
if not task.completed and task.app:
response = marketserver.getJsonInstallResponse('App', self.uri_for('appSpk', appId = task.app, _full = True))
else:
response = marketserver.getJsonResponse()
task.completed = True
task.response = data
task.put()
updateAppStats(dataDict)
self.output(marketserver.constants.jsonMimeType, response)