当前位置: 首页>>代码示例>>Python>>正文


Python Context.request方法代码示例

本文整理汇总了Python中thumbor.context.Context.request方法的典型用法代码示例。如果您正苦于以下问题:Python Context.request方法的具体用法?Python Context.request怎么用?Python Context.request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在thumbor.context.Context的用法示例。


在下文中一共展示了Context.request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: topic

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
 def topic(self):
     config = Config(
         AUTO_WEBP=False,
         RESULT_STORAGE_FILE_STORAGE_ROOT_PATH="/tmp/thumbor/result_storages%s" % (random.choice(['', '/'])))
     context = Context(config=config)
     context.request = RequestParameters(accepts_webp=False)
     return FileStorage(context)
开发者ID:5um1th,项目名称:thumbor,代码行数:9,代码来源:result_storages_file_storage_vows.py

示例2: get_context

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
 def get_context(self):
     cfg = self.get_config()
     ctx = Context(None, cfg, None)
     ctx.request = self.get_request()
     self.context = ctx
     self.file_storage = FileStorage(self.context)
     return ctx
开发者ID:thumbor,项目名称:thumbor,代码行数:9,代码来源:test_file_storage.py

示例3: get_context

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
    def get_context(self):
        conf = Config()
        conf.STATSD_HOST = ''
        ctx = Context(config=conf)
        ctx.request = RequestParameters()

        return ctx
开发者ID:PopSugar,项目名称:thumbor-plugins,代码行数:9,代码来源:test_optimizers.py

示例4: topic

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
        def topic(self):
            config = Config()
            context = Context(None, config, Importer(config))
            context.request = RequestParameters()

            engine = MockInvalidResultEngine(context=context)
            return engine.read()
开发者ID:5um1th,项目名称:thumbor,代码行数:9,代码来源:gif_engine_vows.py

示例5: to_context

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
    def to_context(self):
        self.engine = MockEngine((self.source_width, self.source_height))

        flip_horizontally = self.target_width < 0
        flip_vertically = self.target_height < 0
        self.target_width = self.target_width == "orig" and "orig" or abs(self.target_width)
        self.target_height = self.target_height == "orig" and "orig" or abs(self.target_height)

        importer = Importer(None)
        ctx = Context(server=None, config=Config(), importer=importer)
        ctx.modules.engine = self.engine

        ctx.request = RequestParameters(
            buffer=None,
            debug=False,
            meta=False,
            crop={"left": self.crop_left, "top": self.crop_top, "right": self.crop_right, "bottom": self.crop_bottom},
            adaptive=self.adaptive,
            fit_in=self.fit_in,
            horizontal_flip=flip_horizontally,
            vertical_flip=flip_vertically,
            width=self.target_width,
            height=self.target_height,
            halign=self.halign,
            valign=self.valign,
            focal_points=self.focal_points,
            smart=True,
            extension="JPEG",
            filters=[],
            quality=80,
            image="some.jpeg",
        )

        return ctx
开发者ID:brunomvsouza,项目名称:thumbor,代码行数:36,代码来源:transformer_test_data.py

示例6: get_filter

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
    def get_filter(self, filter_name, params_string="", config_context=None):
        config = Config(
            FILTERS=[filter_name],
            LOADER='thumbor.loaders.file_loader',
            FILE_LOADER_ROOT_PATH=join(dirname(realpath(__file__)), 'fixtures', 'filters')
        )
        importer = Importer(config)
        importer.import_modules()

        req = RequestParameters()

        context = Context(config=config, importer=importer)
        context.request = req
        context.request.engine = context.modules.engine

        if config_context is not None:
            config_context(context)

        self.context = context

        fltr = importer.filters[0]
        fltr.pre_compile()

        context.transformer = Transformer(context)

        return fltr(params_string, context=context)
开发者ID:GDxU,项目名称:thumbor,代码行数:28,代码来源:base.py

示例7: get_context

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
    def get_context(self):
        conf = Config()
        conf.STATSD_HOST = ''
        conf.FFMPEG_PATH = which('ffmpeg')
        ctx = Context(config=conf)
        ctx.request = RequestParameters()
        ctx.request.filters.append('gifv')

        return ctx
开发者ID:gi11es,项目名称:thumbor-debian,代码行数:11,代码来源:test_gifv.py

示例8: topic

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
        def topic(self):
            conf = Config()
            imp = Importer(conf)
            imp.filters = [Filter]
            ctx = Context(None, conf, imp)
            ctx.request = RequestParameters()

            filter_instances = ctx.filters_factory.create_instances(ctx, "format(invalid)")

            filter_instances[0].run()
开发者ID:Hazer,项目名称:thumbor,代码行数:12,代码来源:format_filter_vows.py

示例9: topic

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
        def topic(self):
            conf = Config()
            imp = Importer(conf)
            imp.filters = [Filter]
            ctx = Context(None, conf, imp)
            ctx.request = RequestParameters()

            runner = ctx.filters_factory.create_instances(ctx, "format(invalid)")
            filter_instances = runner.filter_instances[thumbor.filters.PHASE_POST_TRANSFORM]

            filter_instances[0].run()
开发者ID:APSL,项目名称:thumbor,代码行数:13,代码来源:format_filter_vows.py

示例10: get_optimizer

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
    def get_optimizer(self, filters=None, progressive=False):
        conf = Config()
        conf.STATSD_HOST = ''
        conf.JPEGTRAN_PATH = '/somewhere/jpegtran'
        conf.PROGRESSIVE_JPEG = progressive
        req = RequestParameters(filters=filters)
        ctx = Context(config=conf)
        ctx.request = req
        optimizer = Optimizer(ctx)

        return optimizer
开发者ID:gi11es,项目名称:thumbor-debian,代码行数:13,代码来源:test_jpegtran.py

示例11: topic

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
    def topic(self):
        conf = Config()
        req = RequestParameters(quality=100)
        ctx = Context(None, conf, None)
        ctx.request = req

        filters = [Filter]
        compile_filters(filters)
        filter_instances = create_instances(ctx, filters, "quality(10)")

        filter_instances[0].run_filter()
        return ctx.request.quality
开发者ID:MechanisM,项目名称:thumbor,代码行数:14,代码来源:quality_filter_vows.py

示例12: topic

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
        def topic(self, callback):
            self.conn = S3Connection()
            self.conn.create_bucket(s3_bucket)

            config = Config(TC_AWS_RESULT_STORAGE_BUCKET=s3_bucket)
            ctx = Context(config=config, server=get_server('ACME-SEC'))
            ctx.request = Request
            ctx.request.url = 'my-image.jpg'

            storage = Storage(ctx)

            storage.put(IMAGE_BYTES, callback=callback)
开发者ID:NZME,项目名称:aws,代码行数:14,代码来源:result_storage_vows.py

示例13: topic

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
        def topic(self):
            self.conn = S3Connection()
            self.conn.create_bucket(s3_bucket)

            config = Config(RESULT_STORAGE_BUCKET=s3_bucket)
            ctx = Context(config=config, server=get_server('ACME-SEC'))
            ctx.request = Request
            ctx.request.url = 'my-image.jpg'

            storage = Storage(ctx)
            path = storage.put(IMAGE_BYTES)

            return path
开发者ID:guilhermef,项目名称:aws,代码行数:15,代码来源:result_storage_vows.py

示例14: topic

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
        def topic(self):
            conf = Config()
            imp = Importer(conf)
            imp.filters = [Filter]
            ctx = Context(None, conf, imp)
            ctx.request = RequestParameters()

            runner = ctx.filters_factory.create_instances(ctx, "rotate(540)")
            filter_instances = runner.filter_instances[thumbor.filters.PHASE_POST_TRANSFORM]

            filter_instances[0].engine = RotateEngine()
            filter_instances[0].run()

            return filter_instances[0].engine.rotate_val
开发者ID:APSL,项目名称:thumbor,代码行数:16,代码来源:rotate_filter_vows.py

示例15: topic

# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
    def topic(self):
        conf = Config()
        conf.ENGINE = 'thumbor.engines.pil'
        imp = Importer(conf)
        imp.import_modules()
        imp.filters = [Filter]
        ctx = Context(None, conf, imp)

        for item in DATA:
            ctx.modules.engine.image = ctx.modules.engine.gen_image(item[1],'#fff')
            req = RequestParameters(fit_in=True,width=item[0][0],height=item[0][1])
            ctx.request = req

            filter_instances = ctx.filters_factory.create_instances(ctx, "fill(blue)")

            filter_instances[0].run()
            yield (filter_instances[0].engine.image.size,item[2])
开发者ID:amumu,项目名称:thumbor,代码行数:19,代码来源:fill_filter_vows.py


注:本文中的thumbor.context.Context.request方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。