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


Python server.QgsServiceRegistry類代碼示例

本文整理匯總了Python中qgis.server.QgsServiceRegistry的典型用法代碼示例。如果您正苦於以下問題:Python QgsServiceRegistry類的具體用法?Python QgsServiceRegistry怎麽用?Python QgsServiceRegistry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了QgsServiceRegistry類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_1_unregister_services

    def test_1_unregister_services(self):

        reg  = QgsServiceRegistry()
        serv1 = MyService("TEST", "1.0a", "Hello")
        serv2 = MyService("TEST", "1.0b", "Hello")
        serv3 = MyService("TEST", "1.0c", "Hello")

        reg.registerService(serv1)
        reg.registerService(serv2)
        reg.registerService(serv3)

        # Check we get the default version
        service = reg.getService("TEST")
        self.assertEqual( service.version(), "1.0a" )
        
        # Remove one service
        removed = reg.unregisterService("TEST", "1.0a")
        self.assertEqual( removed, 1 )

        # Check that we get the highest version
        service = reg.getService("TEST")
        self.assertEqual( service.version(), "1.0c" )
        
         # Remove all services
        removed = reg.unregisterService("TEST")
        self.assertEqual( removed, 2 )

         # Check that there is no more services available
        service = reg.getService("TEST")
        self.assertIsNone(service)
開發者ID:,項目名稱:,代碼行數:30,代碼來源:

示例2: test_register

    def test_register(self):

        reg = QgsServiceRegistry()

        myserv = MyService("TEST", "1.0", "Hello world")

        reg.registerService( myserv )

        # Retrieve service
        request  = QgsServerRequest("http://DoStufff", QgsServerRequest.GetMethod)
        response = Response()

        service = reg.getService("TEST")
        if service:
            service.executeRequest(request, response)
       
        io = response.io();
        io.seek(0)

        self.assertEqual(QTextStream(io).readLine(), "Hello world")
開發者ID:,項目名稱:,代碼行數:20,代碼來源:

示例3: test_0_version_registration

    def test_0_version_registration(self):

        reg     = QgsServiceRegistry()
        myserv1 = MyService("TEST", "1.1", "Hello")
        myserv2 = MyService("TEST", "1.0", "Hello")
   
        reg.registerService( myserv1 )
        reg.registerService( myserv2)

        service = reg.getService("TEST")
        self.assertIsNotNone(service)
        self.assertEqual(service.version(), "1.1")

        service = reg.getService("TEST", "2.0")
        self.assertIsNotNone(service)
        self.assertEqual(service.version(), "1.1")

        service = reg.getService("TEST", "1.0")
        self.assertIsNotNone(service)
        self.assertEqual(service.version(), "1.0")
開發者ID:,項目名稱:,代碼行數:20,代碼來源:


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