Beispiel #1
0
    def __init__(self, apiRoot):
        # Don't call the parent (Item) constructor, to avoid redefining routes,
        # but do call the grandparent (Resource) constructor
        super(ItemResource, self).__init__()

        self.resourceName = 'item'
        apiRoot.item.route('POST', (':itemId', 'tiles'), self.createTiles)
        apiRoot.item.route('GET', (':itemId', 'tiles'), self.getTilesInfo)
        apiRoot.item.route('DELETE', (':itemId', 'tiles'), self.deleteTiles)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'thumbnail'),
                           self.getTilesThumbnail)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'region'),
                           self.getTilesRegion)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'pixel'),
                           self.getTilesPixel)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'zxy', ':z', ':x', ':y'),
                           self.getTile)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'images'),
                           self.getAssociatedImagesList)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'images', ':image'),
                           self.getAssociatedImage)
        apiRoot.item.route('GET', ('test', 'tiles'), self.getTestTilesInfo)
        apiRoot.item.route('GET', ('test', 'tiles', 'zxy', ':z', ':x', ':y'),
                           self.getTestTile)
        filter_logging.addLoggingFilter(
            'GET (/[^/ ?#]+)*/item/[^/ ?#]+/tiles/zxy(/[^/ ?#]+){3}',
            frequency=250)
        # Cache the model singleton
        self.imageItemModel = ImageItem()
Beispiel #2
0
    def __init__(self, apiRoot):
        # Don't call the parent (Item) constructor, to avoid redefining routes,
        # but do call the grandparent (Resource) constructor
        super(Item, self).__init__()

        self.resourceName = 'item'
        apiRoot.item.route('POST', (':itemId', 'tiles'), self.createTiles)
        apiRoot.item.route('GET', (':itemId', 'tiles'), self.getTilesInfo)
        apiRoot.item.route('DELETE', (':itemId', 'tiles'), self.deleteTiles)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'thumbnail'),
                           self.getTilesThumbnail)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'region'),
                           self.getTilesRegion)
        apiRoot.item.route('GET',
                           (':itemId', 'tiles', 'zxy', ':z', ':x', ':y'),
                           self.getTile)
        apiRoot.item.route('GET', ('test', 'tiles'), self.getTestTilesInfo)
        apiRoot.item.route('GET', ('test', 'tiles', 'zxy', ':z', ':x', ':y'),
                           self.getTestTile)
        filter_logging.addLoggingFilter(
            'GET (/[^/ ?#]+)*/item/[^/ ?#]+/tiles/zxy(/[^/ ?#]+){3}',
            frequency=250)
        # This is added to the system route
        apiRoot.system.route('GET', ('setting', 'large_image'),
                             self.getPublicSettings)
        # Cache the model singleton
        self.imageItemModel = self.model('image_item', 'large_image')
Beispiel #3
0
    def testFilterDuration(self):
        self._checkLogCount(1, 1)
        self._checkLogCount(3, 3)

        regex = 'GET (/[^/ ?#]+)*/system/version[/ ?#]'
        # log every third version request
        filter_logging.addLoggingFilter(regex, duration=3)
        self._checkLogCount(1, 1)
        self._checkLogCount(3, 1, duration=[0, 0, 3.1])
        self._checkLogCount(2, 0, duration=[0, 0])
        self._checkLogCount(1, 1, duration=[3.1])

        self.assertTrue(filter_logging.removeLoggingFilter(regex))
        self._checkLogCount(2, 2, duration=[0, 0])

        self.assertFalse(filter_logging.removeLoggingFilter(regex))
    def testFilterDuration(self):
        self._checkLogCount(1, 1)
        self._checkLogCount(3, 3)

        regex = 'GET (/[^/ ?#]+)*/system/version[/ ?#]'
        # log every third version request
        filter_logging.addLoggingFilter(regex, duration=3)
        self._checkLogCount(1, 1)
        self._checkLogCount(3, 1, duration=[0, 0, 3.1])
        self._checkLogCount(2, 0, duration=[0, 0])
        self._checkLogCount(1, 1, duration=[3.1])

        self.assertTrue(filter_logging.removeLoggingFilter(regex))
        self._checkLogCount(2, 2, duration=[0, 0])

        self.assertFalse(filter_logging.removeLoggingFilter(regex))
Beispiel #5
0
    def __init__(self, apiRoot):
        # Don't call the parent (Item) constructor, to avoid redefining routes,
        # but do call the grandparent (Resource) constructor
        super(ItemResource, self).__init__()

        self.resourceName = 'item'
        apiRoot.item.route('POST', (':itemId', 'tiles'), self.createTiles)
        apiRoot.item.route('POST', (':itemId', 'tiles', 'convert'), self.convertImage)
        apiRoot.item.route('GET', (':itemId', 'tiles'), self.getTilesInfo)
        apiRoot.item.route('DELETE', (':itemId', 'tiles'), self.deleteTiles)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'thumbnail'),
                           self.getTilesThumbnail)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'region'),
                           self.getTilesRegion)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'pixel'),
                           self.getTilesPixel)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'histogram'),
                           self.getHistogram)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'zxy', ':z', ':x', ':y'),
                           self.getTile)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'fzxy', ':frame', ':z', ':x', ':y'),
                           self.getTileWithFrame)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'images'),
                           self.getAssociatedImagesList)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'images', ':image'),
                           self.getAssociatedImage)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'images', ':image', 'metadata'),
                           self.getAssociatedImageMetadata)
        apiRoot.item.route('GET', ('test', 'tiles'), self.getTestTilesInfo)
        apiRoot.item.route('GET', ('test', 'tiles', 'zxy', ':z', ':x', ':y'),
                           self.getTestTile)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'dzi.dzi'),
                           self.getDZIInfo)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'dzi_files', ':level', ':xandy'),
                           self.getDZITile)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'internal_metadata'),
                           self.getInternalMetadata)
        filter_logging.addLoggingFilter(
            'GET (/[^/ ?#]+)*/item/[^/ ?#]+/tiles/zxy(/[^/ ?#]+){3}',
            frequency=250)
        filter_logging.addLoggingFilter(
            'GET (/[^/ ?#]+)*/item/[^/ ?#]+/tiles/dzi_files(/[^/ ?#]+){2}',
            frequency=250)
        # Cache the model singleton
        self.imageItemModel = ImageItem()
Beispiel #6
0
    def testFilter(self):
        self._checkLogCount(1, 1)
        self._checkLogCount(3, 3)

        regex = 'GET (/[^/ ?#]+)*/system/version[/ ?#]'
        # log every third version request
        filter_logging.addLoggingFilter(regex, 3)
        self._checkLogCount(3, 1)
        self._checkLogCount(2, 0)
        self._checkLogCount(1, 1)

        filter_logging.addLoggingFilter(regex, 5)
        self._checkLogCount(10, 2)

        self.assertTrue(filter_logging.removeLoggingFilter(regex))
        self._checkLogCount(2, 2)

        self.assertFalse(filter_logging.removeLoggingFilter(regex))
Beispiel #7
0
    def testFilterFrequency(self):
        self._checkLogCount(1, 1)
        self._checkLogCount(3, 3)

        regex = 'GET (/[^/ ?#]+)*/system/version[/ ?#]'
        # log every third version request
        filter_logging.addLoggingFilter(regex, 3)
        self._checkLogCount(3, 1)
        self._checkLogCount(2, 0)
        self._checkLogCount(1, 1)

        filter_logging.addLoggingFilter(regex, 5)
        self._checkLogCount(10, 2)

        self.assertTrue(filter_logging.removeLoggingFilter(regex))
        self._checkLogCount(2, 2)

        self.assertFalse(filter_logging.removeLoggingFilter(regex))
Beispiel #8
0
 def __init__(self, apiRoot):
     # Avoid redefining routes, call the Resource constructor
     # super(ItemResource, self).__init__()
     super().__init__(apiRoot)
     apiRoot.item.route('POST', (':itemId', 'tiles', 'extended'),
                        self.createTiles)
     apiRoot.item.route('GET', (':itemId', 'tiles', 'extended', 'zxy', ':z', ':x', ':y'),
                        self.getTile)
     # remove and replace original get region route
     apiRoot.item.removeRoute('GET', (':itemId', 'tiles', 'region'))
     apiRoot.item.route('GET', (':itemId', 'tiles', 'extended', 'region'),
                        self.getTilesRegion)
     # apiRoot.item.route('POST', (':itemId', 'tiles', 'extended', 'zxy', ':z', ':x', ':y'),
     # self.saveTile)
     filter_logging.addLoggingFilter(
         'GET (/[^/ ?#]+)*/item/[^/ ?#]+/tiles/zxy(/[^/ ?#]+){3}',
         frequency=250)
     # Cache the model singleton
     self.imageItemModel = LargerImageItem()
Beispiel #9
0
    def testMultipleHandlers(self):
        logRoot = config.getConfig()['logging']['log_root']
        logFile = os.path.join(logRoot, 'second.log')
        fh = logging.FileHandler(logFile)
        cherrypy.log.access_log.addHandler(fh)

        self._checkLogCount(1, 1, logFile)
        self._checkLogCount(3, 3, logFile)

        regex = 'GET (/[^/ ?#]+)*/system/version[/ ?#]'
        # log every third version request
        filter_logging.addLoggingFilter(regex, 3)
        self._checkLogCount(3, 1, logFile)
        self._checkLogCount(2, 0, logFile)
        self._checkLogCount(1, 1, logFile)

        filter_logging.addLoggingFilter(regex, 5)
        self._checkLogCount(10, 2, logFile)

        self.assertTrue(filter_logging.removeLoggingFilter(regex))
        self._checkLogCount(2, 2, logFile)
Beispiel #10
0
    def testMultipleHandlers(self):
        logRoot = config.getConfig()['logging']['log_root']
        logFile = os.path.join(logRoot, 'second.log')
        fh = logging.FileHandler(logFile)
        cherrypy.log.access_log.addHandler(fh)

        self._checkLogCount(1, 1, logFile)
        self._checkLogCount(3, 3, logFile)

        regex = 'GET (/[^/ ?#]+)*/system/version[/ ?#]'
        # log every third version request
        filter_logging.addLoggingFilter(regex, 3)
        self._checkLogCount(3, 1, logFile)
        self._checkLogCount(2, 0, logFile)
        self._checkLogCount(1, 1, logFile)

        filter_logging.addLoggingFilter(regex, 5)
        self._checkLogCount(10, 2, logFile)

        self.assertTrue(filter_logging.removeLoggingFilter(regex))
        self._checkLogCount(2, 2, logFile)
    def __init__(self, apiRoot):
        # Don't call the parent (Item) constructor, to avoid redefining routes,
        # but do call the grandparent (Resource) constructor
        super(Item, self).__init__()

        self.resourceName = 'item'
        apiRoot.item.route('POST', (':itemId', 'tiles'), self.createTiles)
        apiRoot.item.route('GET', (':itemId', 'tiles'), self.getTilesInfo)
        apiRoot.item.route('DELETE', (':itemId', 'tiles'), self.deleteTiles)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'thumbnail'),
                           self.getTilesThumbnail)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'region'),
                           self.getTilesRegion)
        apiRoot.item.route('GET', (':itemId', 'tiles', 'zxy', ':z', ':x', ':y'),
                           self.getTile)
        apiRoot.item.route('GET', ('test', 'tiles'), self.getTestTilesInfo)
        apiRoot.item.route('GET', ('test', 'tiles', 'zxy', ':z', ':x', ':y'),
                           self.getTestTile)
        filter_logging.addLoggingFilter(
            'GET (/[^/ ?#]+)*/item/[^/ ?#]+/tiles/zxy(/[^/ ?#]+){3}',
            frequency=250)
        # Cache the model singleton
        self.imageItemModel = self.model('image_item', 'large_image')