本文整理汇总了Python中globaleaks.rest.apicache.GLApiCache类的典型用法代码示例。如果您正苦于以下问题:Python GLApiCache类的具体用法?Python GLApiCache怎么用?Python GLApiCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GLApiCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put
def put(self, field_id):
"""
Update a single field's attributes.
:param field_id:
:return: the serialized field
:rtype: FieldDesc
:raises FieldIdNotFound: if there is no field with such id.
:raises InvalidInputFormat: if validation fails.
"""
request = self.validate_message(self.request.body,
requests.FieldDesc)
# enforce difference between /admin/field and /admin/fieldtemplate
request['is_template'] = False
response = yield update_field(field_id, request, self.request.language)
# get the updated list of contexts, and update the cache
public_contexts_list = yield get_public_context_list(self.request.language)
GLApiCache.invalidate('contexts')
GLApiCache.set('contexts', self.request.language, public_contexts_list)
self.set_status(202) # Updated
self.finish(response)
示例2: test_invalidate
def test_invalidate(self):
self.assertTrue("passante_di_professione" not in GLApiCache.memory_cache_dict)
pdp_it = yield GLApiCache.get("passante_di_professione", "it", self.mario, "come", "una", "catapulta!")
self.assertTrue("passante_di_professione" in GLApiCache.memory_cache_dict)
self.assertEqual(pdp_it, "come una catapulta!")
yield GLApiCache.invalidate("passante_di_professione")
self.assertTrue("passante_di_professione" not in GLApiCache.memory_cache_dict)
示例3: put
def put(self, lang):
request = json.loads(self.request.body)
yield update_custom_texts(lang, request)
GLApiCache.invalidate()
self.set_status(202) # Updated
示例4: test_get
def test_get(self):
self.assertTrue("passante_di_professione" not in GLApiCache.memory_cache_dict)
pdp_it = yield GLApiCache.get("passante_di_professione", "it", self.mario, "come", "una", "catapulta!")
pdp_en = yield GLApiCache.get("passante_di_professione", "en", self.mario, "like", "a", "catapult!")
self.assertTrue("passante_di_professione" in GLApiCache.memory_cache_dict)
self.assertTrue("it" in GLApiCache.memory_cache_dict['passante_di_professione'])
self.assertTrue("en" in GLApiCache.memory_cache_dict['passante_di_professione'])
self.assertEqual(pdp_it, "come una catapulta!")
self.assertEqual(pdp_en, "like a catapult!")
示例5: test_set
def test_set(self):
self.assertTrue("passante_di_professione" not in GLApiCache.memory_cache_dict)
pdp_it = yield GLApiCache.get("passante_di_professione", "it", self.mario, "come", "una", "catapulta!")
self.assertTrue("passante_di_professione" in GLApiCache.memory_cache_dict)
self.assertTrue(pdp_it == "come una catapulta!")
yield GLApiCache.set("passante_di_professione", "it", "ma io ho visto tutto!")
self.assertTrue("passante_di_professione" in GLApiCache.memory_cache_dict)
pdp_it = yield GLApiCache.get("passante_di_professione", "it", self.mario, "already", "cached")
self.assertEqual(pdp_it, "ma io ho visto tutto!")
示例6: delete
def delete(self, context_id):
"""
Delete the specified context.
Request: AdminContextDesc
Response: None
Errors: InvalidInputFormat, ContextIdNotFound
"""
yield delete_context(context_id)
GLApiCache.invalidate()
示例7: delete
def delete(self, questionnaire_id):
"""
Delete the specified questionnaire.
Request: AdminQuestionnaireDesc
Response: None
Errors: InvalidInputFormat, QuestionnaireIdNotFound
"""
yield delete_questionnaire(questionnaire_id)
GLApiCache.invalidate()
示例8: delete
def delete(self, field_id):
"""
Delete a single field template.
:param field_id:
:raises FieldIdNotFound: if there is no field with such id.
"""
yield delete_field(field_id)
GLApiCache.invalidate()
示例9: delete
def delete(self, step_id):
"""
Delete the specified step.
:param step_id:
:raises StepIdNotFound: if there is no step with such id.
:raises InvalidInputFormat: if validation fails.
"""
yield delete_step(step_id)
GLApiCache.invalidate()
示例10: post
def post(self):
request = self.validate_message(self.request.body,
requests.WizardDesc)
# Wizard will raise exceptions if there are any errors with the request
yield wizard(request, self.request.language)
# cache must be updated in order to set wizard_done = True
yield serialize_node(self.request.language)
GLApiCache.invalidate()
self.set_status(201) # Created
示例11: delete
def delete(self, user_id):
"""
Delete the specified user.
Parameters: user_id
Request: None
Response: None
Errors: InvalidInputFormat, UserIdNotFound
"""
yield delete_user(user_id)
GLApiCache.invalidate()
示例12: delete
def delete(self, questionnaire_id):
"""
Delete the specified questionnaire.
Request: AdminQuestionnaireDesc
Response: None
Errors: InvalidInputFormat, QuestionnaireIdNotFound
"""
yield delete_questionnaire(questionnaire_id)
GLApiCache.invalidate()
self.set_status(200) # Ok and return no content
self.finish()
示例13: get
def get(self):
"""
Get the Ahmia.fi descriptor
"""
node_info = yield GLApiCache.get("node", self.request.language, serialize_node, self.request.language)
if node_info["ahmia"]:
ret = yield GLApiCache.get("ahmia", self.request.language, serialize_ahmia, self.request.language)
self.finish(ret)
else: # in case of disabled option we return 404
self.set_status(404)
self.finish()
示例14: delete
def delete(self, context_id):
"""
Delete the specified context.
Request: AdminContextDesc
Response: None
Errors: InvalidInputFormat, ContextIdNotFound
"""
yield delete_context(context_id)
GLApiCache.invalidate()
self.set_status(200) # Ok and return no content
self.finish()
示例15: post
def post(self):
"""
"""
request = self.validate_message(self.request.body,
requests.WizardFirstSetupDesc)
yield wizard(request, self.request.language)
# cache must be updated in particular to set wizard_done = True
public_node_desc = yield serialize_node(self.request.language)
GLApiCache.invalidate()
self.set_status(201) # Created