def setUp(self): super(BaseFilterTestCase, self).setUp() self.context = self.get_context() self.factory = FiltersFactory( [MyFilter, StringFilter, OptionalParamFilter, PreLoadFilter] ) self.runner = self.get_runner()
def __init__(self, server=None, config=None, importer=None, request_handler=None): self.server = server self.config = config if importer: self.modules = ContextImporter(self, importer) if importer.metrics: self.metrics = importer.metrics(config) else: self.metrics = Metrics(config) else: self.modules = None self.metrics = Metrics(config) self.app_class = 'thumbor.app.ThumborServiceApp' if hasattr(self.config, 'APP_CLASS'): self.app_class = self.config.APP_CLASS if hasattr(self.server, 'app_class') and self.server.app_class != 'thumbor.app.ThumborServiceApp': self.app_class = self.server.app_class self.filters_factory = FiltersFactory(self.modules.filters if self.modules else []) self.request_handler = request_handler self.statsd_client = self.metrics # TODO statsd_client is deprecated, remove me on next minor version bump self.thread_pool = ThreadPool.instance(getattr(config, 'ENGINE_THREADPOOL_SIZE', 0)) self.headers = {}
def __init__(self, server=None, config=None, importer=None, request_handler=None): self.server = server self.config = config if importer: self.modules = ContextImporter(self, importer) if importer.metrics: self.metrics = importer.metrics(config) else: self.metrics = Metrics(config) else: self.modules = None self.metrics = Metrics(config) self.app_class = "thumbor.app.ThumborServiceApp" if hasattr(self.config, "APP_CLASS"): self.app_class = self.config.APP_CLASS if (hasattr(self.server, "app_class") and self.server.app_class != "thumbor.app.ThumborServiceApp"): self.app_class = self.server.app_class self.filters_factory = FiltersFactory( self.modules.filters if self.modules else []) self.request_handler = request_handler self.thread_pool = ThreadPool.instance( getattr(config, "ENGINE_THREADPOOL_SIZE", 0)) self.headers = {}
def __init__(self, server=None, config=None, importer=None): self.server = server self.config = config if importer: self.modules = ContextImporter(self, importer) else: self.modules = None self.filters_factory = FiltersFactory( self.modules.filters if self.modules else [])
def topic(self): class Any: pass ctx = Any() ctx.modules = Any() ctx.modules.engine = Any() fact = FiltersFactory([MyFilter, StringFilter]) return (fact, ctx)
def topic(self): class Any: pass ctx = Any() ctx.modules = Any() engine = Any() def is_multiple(): return False engine.is_multiple = is_multiple ctx.modules.engine = engine fact = FiltersFactory([MyFilter, StringFilter, OptionalParamFilter]) return (fact, ctx)
def __init__(self, server=None, config=None, importer=None, request_handler=None): self.server = server self.config = config if importer: self.modules = ContextImporter(self, importer) else: self.modules = None self.filters_factory = FiltersFactory( self.modules.filters if self.modules else []) self.request_handler = request_handler self.statsd_client = ThumborStatsClient(config)
def __init__(self, server=None, config=None, importer=None, request_handler=None): self.server = server self.config = config if importer: self.modules = ContextImporter(self, importer) else: self.modules = None self.filters_factory = FiltersFactory( self.modules.filters if self.modules else []) self.request_handler = request_handler self.statsd_client = ThumborStatsClient.instance(config) self.thread_pool = ThreadPool.instance( getattr(config, 'ENGINE_THREADPOOL_SIZE', 0))
def __init__(self, server=None, config=None, importer=None, request_handler=None): ''' Class responsible for containing: * Server Configuration Parameters (port, ip, key, etc); * Configurations read from config file (or defaults); * Importer with imported modules (engine, filters, detectors, etc); * Request Parameters (width, height, smart, meta, etc). Each instance of this class MUST be unique per request. This class should not be cached in the server. :param server: :param config: :param importer: :param request_handler: ''' ThumborContext.__init__( self, server=server, config=config, importer=None, # Always load our ContextImporter request_handler=request_handler) # Load our ContextImporter if importer: self.modules = ContextImporter(self, importer) self.filters_factory = FiltersFactory(self.modules.filters) if importer.metrics: self.metrics = importer.metrics(config) else: self.metrics = Metrics(config)