Пример #1
0
    def _grids(self, caches):
        grids = []

        if 'grids' in self.conf:
            # grids available for all caches
            available_grids = reduce(operator.and_,
                                     (set(cache) for cache in caches.values()))
            for grid_name in self.conf['grids']:
                if grid_name not in available_grids:
                    raise SeedConfigurationError('%s not defined for caches' %
                                                 grid_name)
                grids.append(grid_name)
        else:
            # check that all caches have the same grids configured
            last = []
            for cache_grids in (set(iterkeys(cache))
                                for cache in itervalues(caches)):
                if not last:
                    last = cache_grids
                else:
                    if last != cache_grids:
                        raise SeedConfigurationError(
                            'caches in same seed task require identical grids')
            grids = list(last or [])
        return grids
Пример #2
0
    def __init__(self, type_key, specs):
        self.type_key = type_key
        self.specs = specs

        for v in itervalues(specs):
            if not isinstance(v, dict):
                raise ValueError('%s requires dict subspecs', self.__class__)
            if self.type_key not in v:
                v[self.type_key] = str()
Пример #3
0
    def __init__(self, type_key, specs):
        self.type_key = type_key
        self.specs = specs

        for v in itervalues(specs):
            if not isinstance(v, dict):
                raise ValueError('%s requires dict subspecs', self.__class__)
            if self.type_key not in v:
                v[self.type_key] = str()
Пример #4
0
 def authorized_tile_layers(self, env):
     if 'mapproxy.authorize' in env:
         result = env['mapproxy.authorize']('wmts', [l for l in self.layers],
             query_extent=None, environ=env)
         if result['authorized'] == 'unauthenticated':
             raise RequestError('unauthorized', status=401)
         if result['authorized'] == 'full':
             return self.layers.values()
         if result['authorized'] == 'none':
             raise RequestError('forbidden', status=403)
         allowed_layers = []
         for layer in itervalues(self.layers):
             if result['layers'].get(layer.name, {}).get('tile', False) == True:
                 allowed_layers.append(layer)
         return allowed_layers
     else:
         return self.layers.values()
Пример #5
0
 def authorized_tile_layers(self, env):
     if 'mapproxy.authorize' in env:
         result = env['mapproxy.authorize']('wmts', [l for l in self.layers],
             query_extent=None, environ=env)
         if result['authorized'] == 'unauthenticated':
             raise RequestError('unauthorized', status=401)
         if result['authorized'] == 'full':
             return self.layers.values()
         if result['authorized'] == 'none':
             raise RequestError('forbidden', status=403)
         allowed_layers = []
         for layer in itervalues(self.layers):
             if result['layers'].get(layer.name, {}).get('tile', False) == True:
                 allowed_layers.append(layer)
         return allowed_layers
     else:
         return self.layers.values()
Пример #6
0
    def _grids(self, caches):
        grids = []

        if 'grids' in self.conf:
            # grids available for all caches
            available_grids = reduce(operator.and_, (set(cache) for cache in caches.values()))
            for grid_name in self.conf['grids']:
                if grid_name not in available_grids:
                    raise SeedConfigurationError('%s not defined for caches' % grid_name)
                grids.append(grid_name)
        else:
            # check that all caches have the same grids configured
            last = []
            for cache_grids in (set(iterkeys(cache)) for cache in itervalues(caches)):
                if not last:
                    last = cache_grids
                else:
                    if last != cache_grids:
                        raise SeedConfigurationError('caches in same seed task require identical grids')
            grids = list(last or [])
        return grids