本文整理汇总了Python中wagtail.wagtailembeds.finders.get_default_finder函数的典型用法代码示例。如果您正苦于以下问题:Python get_default_finder函数的具体用法?Python get_default_finder怎么用?Python get_default_finder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_default_finder函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_embed
def get_embed(url, max_width=None, finder=None):
# Check database
try:
return Embed.objects.get(url=url, max_width=max_width)
except Embed.DoesNotExist:
pass
# Get/Call finder
if not finder:
finder = get_default_finder()
embed_dict = finder(url, max_width)
# Make sure width and height are valid integers before inserting into database
try:
embed_dict['width'] = int(embed_dict['width'])
except (TypeError, ValueError):
embed_dict['width'] = None
try:
embed_dict['height'] = int(embed_dict['height'])
except (TypeError, ValueError):
embed_dict['height'] = None
# Make sure html field is valid
if 'html' not in embed_dict or not embed_dict['html']:
embed_dict['html'] = ''
# Create database record
embed, created = Embed.objects.get_or_create(
url=url,
max_width=max_width,
defaults=embed_dict,
)
# Save
embed.last_updated = datetime.now()
embed.save()
return embed
示例2: test_find_oembed_when_embedly_key_set
def test_find_oembed_when_embedly_key_set(self):
# WAGTAILEMBEDS_EMBED_FINDER always takes precedence
self.assertEqual(get_default_finder(), wagtail_oembed)
示例3: test_find_old_oembed
def test_find_old_oembed(self):
self.assertEqual(get_default_finder(), wagtail_oembed)
示例4: test_find_oembed_from_module
def test_find_oembed_from_module(self):
self.assertEqual(get_default_finder(), wagtail_oembed)
示例5: test_find_embedly
def test_find_embedly(self):
self.assertEqual(get_default_finder(), wagtail_embedly)
示例6: test_defaults_to_embedly_when_embedly_key_set
def test_defaults_to_embedly_when_embedly_key_set(self):
self.assertEqual(get_default_finder(), wagtail_embedly)