def add_pattern(pattern, base_path, enable_cache=False): """ Add the routing pattern for the resource path prefix. :param pattern: a routing pattern. It can be a Python-compatible regular expression. :param base_path: a path prefix of the resource corresponding to the routing pattern. :param enable_cache: a flag to indicate whether any loaded resources need to be cached on the first request. """ ResourceService._logger.debug('add URL pattern "%s" for "%s"' % (pattern, base_path)) ResourceService._patterns[pattern] = { 'base_path': resolve_file_path(base_path), 'cacheable': enable_cache } ResourceService._pattern_order.append(pattern)
def _register_imagination_services(self, configuration, base_path): """ Register services. """ service_blocks = configuration.children('service') for service_block in service_blocks: service_config_path = service_block.data() # If the file path contains ':', treat the leading part for the full # module name and re-assembles the file path. config_file_path = resolve_file_path(service_config_path) if service_config_path[0] != '/': config_file_path = os.path.join(base_path, service_config_path) self._logger.info('Loading services from {}'.format(config_file_path)) self._service_assembler.load(config_file_path)