當前位置: 首頁>>代碼示例>>Python>>正文


Python base.GLApiCache類代碼示例

本文整理匯總了Python中globaleaks.handlers.base.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)
開發者ID:RuanAragao,項目名稱:GlobaLeaks,代碼行數:25,代碼來源:field.py

示例2: put

    def put(self, *uriargs):
        """
        Request: adminNodeDesc
        Response: adminNodeDesc
        Errors: InvalidInputFormat

        Changes the node public node configuration settings.
        """
        request = self.validate_message(self.request.body,
                requests.adminNodeDesc)

        yield update_node(request, language=self.request.language)

        # align the memory variables with the new updated data
        yield import_memory_variables()

        node_description = yield admin_serialize_node(self.request.language)

        # update 'node' cache calling the 'public' side of /node
        public_node_desc = yield anon_serialize_node(self.request.language)
        GLApiCache.invalidate('node')
        GLApiCache.set('node', self.request.language, public_node_desc)

        self.set_status(202) # Updated
        self.finish(node_description)
開發者ID:mmaker,項目名稱:GlobaLeaks,代碼行數:25,代碼來源:__init__.py

示例3: post

    def post(self, *uriargs):
        """
        Create a new field.

        Request: FieldDesc
        Response: FieldDesc
        Errors: InvalidInputFormat, FieldIdNotFound
        """
        tmp = json.loads(self.request.body)
        if 'template_id' in tmp and tmp['template_id'] != '':
            request = self.validate_message(self.request.body,
                                            requests.FieldDescFromTemplate)
        else:
            request = self.validate_message(self.request.body,
                                            requests.FieldDesc)

        # enforce difference between /admin/field and /admin/fieldtemplate
        request['is_template'] = False
        response = yield create_field(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(201)
        self.finish(response)
開發者ID:mmaker,項目名稱:GlobaLeaks,代碼行數:27,代碼來源:field.py

示例4: 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)
開發者ID:globaleaks,項目名稱:GLBackend-outdated,代碼行數:7,代碼來源:test_cache.py

示例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!")
開發者ID:globaleaks,項目名稱:GLBackend-outdated,代碼行數:9,代碼來源:test_cache.py

示例6: 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!")
開發者ID:globaleaks,項目名稱:GLBackend-outdated,代碼行數:9,代碼來源:test_cache.py

示例7: get

    def get(self, *uriargs):

        node_info = yield GLApiCache.get('node', self.request.language,
                                         anon_serialize_node, self.request.language)

        if node_info['ahmia']:
            ret = yield GLApiCache.get('ahmia', self.request.language,
                                   anon_serialize_ahmia, self.request.language)

            self.finish(ret)
        else: # in case of disabled option we return 404
            self.set_status(404)
            self.finish()
開發者ID:mmaker,項目名稱:GlobaLeaks,代碼行數:13,代碼來源:node.py

示例8: 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()
開發者ID:RuanAragao,項目名稱:GlobaLeaks,代碼行數:13,代碼來源:__init__.py

示例9: put

    def put(self):
        """
        Update the node infos.

        Request: AdminNodeDesc
        Response: AdminNodeDesc
        Errors: InvalidInputFormat
        """
        request = self.validate_message(self.request.body,
                                        requests.AdminNodeDesc)

        node_description = yield update_node(request, True, self.request.language)
        GLApiCache.invalidate()

        self.set_status(202) # Updated
        self.finish(node_description)
開發者ID:RuanAragao,項目名稱:GlobaLeaks,代碼行數:16,代碼來源:__init__.py

示例10: post

    def post(self):
        """
        Get the specified receiver.

        Request: AdminReceiverDesc
        Response: AdminReceiverDesc
        Errors: InvalidInputFormat, ContextIdNotFound
        """
        request = self.validate_message(self.request.body,
                                        requests.AdminReceiverDesc)

        response = yield create_receiver(request, self.request.language)
        GLApiCache.invalidate()

        self.set_status(201) # Created
        self.finish(response)
開發者ID:RuanAragao,項目名稱:GlobaLeaks,代碼行數:16,代碼來源:__init__.py

示例11: get

 def get(self):
     """
     Gets all the receivers.
     """
     ret = yield GLApiCache.get('receivers', self.request.language,
                                get_public_receiver_list, self.request.language)
     self.finish(ret)
開發者ID:RuanAragao,項目名稱:GlobaLeaks,代碼行數:7,代碼來源:node.py

示例12: delete

    def delete(self, field_id, *uriargs):
        """
        Delete a single field.

        Request: None
        Response: None
        Errors: InvalidInputFormat, FieldIdNotFound
        """
        yield delete_field(field_id, False)

        # 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(200)
開發者ID:mmaker,項目名稱:GlobaLeaks,代碼行數:16,代碼來源:field.py

示例13: delete

    def delete(self, field_id):
        """
        Delete a single field.

        :param field_id:
        :raises FieldIdNotFound: if there is no field with such id.
        :raises InvalidInputFormat: if validation fails.
        """
        yield delete_field(field_id, False)

        # 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(200)
開發者ID:RuanAragao,項目名稱:GlobaLeaks,代碼行數:16,代碼來源:field.py

示例14: get

    def get(self, field_id, *uriargs):
        """
        Get the field identified by field_id

        :param field_id:
        :rtype: FieldDesc
        :raises FieldIdNotFound: if there is no field with such id.
        :raises InvalidInputFormat: if validation fails.
        """
        response = yield get_field(field_id, False, 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(200)
        self.finish(response)
開發者ID:mmaker,項目名稱:GlobaLeaks,代碼行數:18,代碼來源:field.py

示例15: initialization

    def initialization(self):
        self.responses = []

        def mock_write(cls, response=None):
            # !!!
            # Here we are making the assumption that every time write() get's
            # called it contains *all* of the response message.
            if response:
                self.responses.append(response)

        self._handler.write = mock_write
        # we make the assumption that we will always use call finish on write.
        self._handler.finish = mock_write

        # we need to reset settings.session to keep each test independent
        GLSetting.sessions = dict()

        # we need to reset GLApiCache to keep each test independent
        GLApiCache.invalidate()
開發者ID:mmaker,項目名稱:GlobaLeaks,代碼行數:19,代碼來源:helpers.py


注:本文中的globaleaks.handlers.base.GLApiCache類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。