本文整理汇总了Python中thumbor.config.Config.ALLOWED_SOURCES方法的典型用法代码示例。如果您正苦于以下问题:Python Config.ALLOWED_SOURCES方法的具体用法?Python Config.ALLOWED_SOURCES怎么用?Python Config.ALLOWED_SOURCES使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thumbor.config.Config
的用法示例。
在下文中一共展示了Config.ALLOWED_SOURCES方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_with_allowed_sources
# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import ALLOWED_SOURCES [as 别名]
def test_with_allowed_sources(self):
config = Config()
config.ALLOWED_SOURCES = [
's.glbimg.com',
re.compile(r'https://www\.google\.com/img/.*')
]
ctx = Context(None, config, None)
expect(
loader.validate(
ctx,
'http://www.google.com/logo.jpg'
)
).to_be_false()
expect(
loader.validate(
ctx,
'http://s2.glbimg.com/logo.jpg'
)
).to_be_false()
expect(
loader.validate(
ctx,
'/glob=:sfoir%20%20%3Co-pmb%20%20%20%20_%20%20%20%200%20%20g.-%3E%3Ca%20hplass='
)
).to_be_false()
expect(
loader.validate(
ctx,
'https://www.google.com/img/logo.jpg'
)
).to_be_true()
expect(
loader.validate(ctx, 'http://s.glbimg.com/logo.jpg')).to_be_true()
示例2: topic
# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import ALLOWED_SOURCES [as 别名]
def topic(self):
url = self.get_url('/')
loader.http_client = self._http_client
config = Config()
config.ALLOWED_SOURCES = ['s.glbimg.com']
ctx = Context(None, config, None)
return loader.load, ctx, url
示例3: test_without_allowed_sources
# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import ALLOWED_SOURCES [as 别名]
def test_without_allowed_sources(self):
config = Config()
config.ALLOWED_SOURCES = []
ctx = Context(None, config, None)
is_valid = loader.validate(ctx, 'https://www.google.com/logo.jpg')
expect(is_valid).to_be_true()
is_valid = loader.validate(ctx, 'http://www.google.com/logo.jpg')
expect(is_valid).to_be_false()
示例4: test_with_allowed_sources
# 需要导入模块: from thumbor.config import Config [as 别名]
# 或者: from thumbor.config.Config import ALLOWED_SOURCES [as 别名]
def test_with_allowed_sources(self):
config = Config()
config.ALLOWED_SOURCES = ["s.glbimg.com"]
ctx = Context(None, config, None)
expect(loader.validate(ctx, "http://www.google.com/logo.jpg")).to_be_false()
expect(loader.validate(ctx, "http://s2.glbimg.com/logo.jpg")).to_be_false()
expect(
loader.validate(ctx, "/glob=:sfoir%20%20%3Co-pmb%20%20%20%20_%20%20%20%200%20%20g.-%3E%3Ca%20hplass=")
).to_be_false()
expect(loader.validate(ctx, "http://s.glbimg.com/logo.jpg")).to_be_true()