• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python theme.render函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中udata.theme.render函数的典型用法代码示例。如果您正苦于以下问题:Python render函数的具体用法?Python render怎么用?Python render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: send

def send(subject, recipients, template_base, **kwargs):
    '''
    Send a given email to multiple recipients.

    User prefered language is taken in account.
    To translate the subject in the right language, you should ugettext_lazy
    '''
    sender = kwargs.pop('sender', None)
    if not isinstance(recipients, (list, tuple)):
        recipients = [recipients]

    debug = current_app.config.get('DEBUG')
    connection = debug and dummyconnection or mail.connect

    with connection() as conn:
        for recipient in recipients:
            lang = i18n._default_lang(recipient)
            with i18n.language(lang):
                log.debug(
                    'Sending mail "%s" to recipient "%s"', subject, recipient)
                msg = Message(subject, sender=sender,
                              recipients=[recipient.email])
                msg.body = theme.render(
                    'mail/{0}.txt'.format(template_base), subject=subject,
                    sender=sender, recipient=recipient, **kwargs)
                msg.html = theme.render(
                    'mail/{0}.html'.format(template_base), subject=subject,
                    sender=sender, recipient=recipient, **kwargs)
                if debug:
                    log.debug(msg.body)
                    log.debug(msg.html)
                else:
                    conn.send(msg)
开发者ID:noirbizarre,项目名称:udata,代码行数:33,代码来源:mail.py


示例2: nec_mergitur

def nec_mergitur():
    datasets = (Dataset.objects(badges__kind=NECMERGITUR).visible()
                .order_by('-metrics.followers'))
    return theme.render('nec_mergitur.html',
                        datasets=datasets,
                        badge=NECMERGITUR,
                        nb_displayed_datasets=NB_DISPLAYED_DATASETS)
开发者ID:opendatalu,项目名称:udata-gouvlu,代码行数:7,代码来源:views.py


示例3: get

 def get(self):
     args = oembed_parser.parse_args()
     url = urlparse.urlparse(args['url'])
     try:
         API, VERSION, item_kind, item_id = url.path.split('/')[1:-1]
     except (ValueError, IndexError):
         return api.abort(400, 'Invalid URL.')
     if item_kind == 'datasets':
         try:
             item = Dataset.objects.get(id=item_id)
         except (db.ValidationError, Dataset.DoesNotExist):
             return api.abort(400, 'Incorrect ID.')
         template = 'embed-dataset.html'
     else:
         return api.abort(400, 'Invalid object type.')
     width = maxwidth = 1000
     height = maxheight = 200
     html = theme.render(template, **{
         'width': width,
         'height': height,
         'item': item,
     })
     return output_json({
         'type': 'rich',
         'version': '1.0',
         'html': html,
         'width': width,
         'height': height,
         'maxwidth': maxwidth,
         'maxheight': maxheight,
     }, 200)
开发者ID:ldolberg,项目名称:udata,代码行数:31,代码来源:__init__.py


示例4: openfield16

def openfield16():
    datasets = (Dataset.objects(badges__kind=OPENFIELD16).visible()
                .order_by('-metrics.followers'))
    return theme.render('openfield16.html',
                        datasets=datasets,
                        badge=OPENFIELD16,
                        nb_displayed_datasets=NB_DISPLAYED_DATASETS)
开发者ID:davidbgk,项目名称:udata-gouvfr,代码行数:7,代码来源:views.py


示例5: render_search

def render_search():
    params = multi_to_dict(request.args)
    params['facets'] = True
    # We only fetch relevant data for the given filter.
    if 'tag' in params:
        search_queries = [
            search.SearchQuery(Dataset, **params),
            search.SearchQuery(Reuse, **params)
        ]
        results_labels = ['datasets', 'reuses']
    elif 'badge' in params:
        search_queries = [
            search.SearchQuery(Dataset, **params),
            search.SearchQuery(Organization, **params)
        ]
        results_labels = ['datasets', 'organizations']
    else:
        search_queries = [
            search.SearchQuery(Dataset, **params),
            search.SearchQuery(Reuse, **params),
            search.SearchQuery(Organization, **params),
            search.SearchQuery(User, **params)
        ]
        results_labels = ['datasets', 'reuses', 'organizations', 'users']
    results = search.multiquery(*search_queries)
    return theme.render('search.html',
                        **dict(zip(results_labels, results)))
开发者ID:ldolberg,项目名称:udata,代码行数:27,代码来源:views.py


示例6: get

    def get(self):
        """ The returned payload is a list of OEmbed formatted responses.

        See: http://oembed.com/

        The `references` are composed by a keyword (`kind`) followed by
        the `id` each of those separated by commas.
        E.g: dataset-5369992aa3a729239d205183,territory-fr-town-75056-comptes

        Only datasets and territories are supported for now.
        """
        args = oembeds_parser.parse_args()
        references = args['references'].split(',')
        result = []
        for item_reference in references:
            try:
                item_kind, item_id = item_reference.split('-', 1)
            except ValueError:
                return api.abort(400, 'Invalid ID.')
            if item_kind == 'dataset':
                try:
                    item = Dataset.objects.get(id=item_id)
                except (db.ValidationError, Dataset.DoesNotExist):
                    return api.abort(400, 'Unknown dataset ID.')
            elif (item_kind == 'territory' and
                    current_app.config.get('ACTIVATE_TERRITORIES')):
                from udata.models import TERRITORY_DATASETS
                try:
                    country, town, code, kind = item_id.split('-')
                except ValueError:
                    return api.abort(400, 'Invalid territory ID.')
                try:
                    geozone = GeoZone.objects.get(code=code)
                except GeoZone.DoesNotExist:
                    return api.abort(400, 'Unknown territory identifier.')
                if kind in TERRITORY_DATASETS:
                    item = TERRITORY_DATASETS[kind](geozone)
                else:
                    return api.abort(400, 'Unknown kind of territory.')
            else:
                return api.abort(400, 'Invalid object type.')
            width = maxwidth = 1000
            height = maxheight = 200
            html = theme.render('embed-dataset.html', **{
                'width': width,
                'height': height,
                'item': item,
                'item_reference': item_reference,
            })
            result.append({
                'type': 'rich',
                'version': '1.0',
                'html': html,
                'width': width,
                'height': height,
                'maxwidth': maxwidth,
                'maxheight': maxheight,
            })
        return output_json(result, 200)
开发者ID:michelbl,项目名称:udata,代码行数:59,代码来源:api.py


示例7: reuses

def reuses(topic):
    kwargs = multi_to_dict(request.args)
    kwargs.update(topic=topic)

    return theme.render('topic/reuses.html',
        topic=topic,
        reuses=TopicSearchQuery(Reuse, facets=True, **kwargs).execute()
    )
开发者ID:guillo-w,项目名称:udata,代码行数:8,代码来源:views.py


示例8: show

def show(post):
    others = Post.objects(id__ne=post.id).published()
    older = others(published__lt=post.published)
    newer = others(published__gt=post.published)
    return theme.render('post/display.html',
                        post=post,
                        previous_post=older.first(),
                        next_post=newer.first())
开发者ID:odtvince,项目名称:udata,代码行数:8,代码来源:views.py


示例9: datasets

def datasets(topic):
    kwargs = multi_to_dict(request.args)
    kwargs.update(topic=topic)

    return theme.render('topic/datasets.html',
        topic=topic,
        datasets=TopicSearchQuery(Dataset, facets=True, **kwargs).execute()
    )
开发者ID:guillo-w,项目名称:udata,代码行数:8,代码来源:views.py


示例10: climate_change_challenge

def climate_change_challenge():
    partners = Organization.objects(slug__in=C3_PARTNERS)
    datasets = (Dataset.objects(badges__kind=C3).visible()
                .order_by('-metrics.followers'))
    return theme.render('c3.html',
                        partners=partners,
                        datasets=datasets,
                        badge=C3,
                        nb_displayed_datasets=NB_DISPLAYED_DATASETS)
开发者ID:opendatalu,项目名称:udata-gouvlu,代码行数:9,代码来源:views.py


示例11: home

def home():
    context = {
        'recent_datasets': Dataset.objects.visible(),
        'recent_reuses': Reuse.objects(featured=True).visible(),
        'last_post': Post.objects(private=False).first(),
    }
    processor = theme.current.get_processor('home')
    context = processor(context)
    return theme.render('home.html', **context)
开发者ID:anukat2015,项目名称:udata,代码行数:9,代码来源:views.py


示例12: dataconnexions5

def dataconnexions5():
    reuses = Reuse.objects(badges__kind=DATACONNEXIONS_5_CANDIDATE).visible()

    categories = [{
        'tag': tag,
        'label': label,
        'description': description,
        'reuses': reuses(tags=tag),
    } for tag, label, description in DATACONNEXIONS_5_CATEGORIES]
    return theme.render('dataconnexions-5.html', categories=categories)
开发者ID:opendatalu,项目名称:udata-gouvlu,代码行数:10,代码来源:views.py


示例13: test_oembed_for_dataset_with_organization

    def test_oembed_for_dataset_with_organization(self, api):
        '''It should fetch a dataset in the oembed format with org.'''
        organization = OrganizationFactory()
        dataset = DatasetFactory(organization=organization)

        url = url_for('api.oembed', url=dataset.external_url)
        response = api.get(url)
        assert200(response)

        card = theme.render('dataset/card.html', dataset=dataset)
        assert card in response.json['html']
开发者ID:odtvince,项目名称:udata,代码行数:11,代码来源:test_oembed_api.py


示例14: dataconnexions6

def dataconnexions6():
    # Use tags until we are sure all reuse are correctly labeled
    # reuses = Reuse.objects(badges__kind=DATACONNEXIONS_6_CANDIDATE)
    reuses = Reuse.objects(tags='dataconnexions-6').visible()

    categories = [{
        'tag': tag,
        'label': label,
        'description': description,
        'reuses': reuses(tags=tag),
    } for tag, label, description in DATACONNEXIONS_6_CATEGORIES]
    return theme.render('dataconnexions-6.html', categories=categories)
开发者ID:opendatalu,项目名称:udata-gouvlu,代码行数:12,代码来源:views.py


示例15: authorize

def authorize(*args, **kwargs):
    if request.method == 'GET':
        client_id = kwargs.get('client_id')
        client = OAuth2Client.objects.get(id=ObjectId(client_id))
        kwargs['client'] = client
        return theme.render('api/oauth_authorize.html', oauth=kwargs)
    elif request.method == 'POST':
        accept = 'accept' in request.form
        decline = 'decline' in request.form
        return accept and not decline
    else:
        abort(405)
开发者ID:anukat2015,项目名称:udata,代码行数:12,代码来源:oauth2.py


示例16: display

def display(topic):
    specs = {
        'recent_datasets': TopicSearchQuery(Dataset, sort='-created', page_size=9, topic=topic),
        'featured_reuses': TopicSearchQuery(Reuse, featured=True, page_size=6, topic=topic),
    }
    keys, queries = zip(*specs.items())

    results = search.multiquery(*queries)

    return theme.render('topic/display.html',
        topic=topic,
        **dict(zip(keys, results))
    )
开发者ID:guillo-w,项目名称:udata,代码行数:13,代码来源:views.py


示例17: datasets

def datasets(topic):
    kwargs = multi_to_dict(request.args)
    kwargs.pop('topic', None)
    topic_search = topic_search_for(topic,
                                    DatasetSearch,
                                    facets=True,
                                    **kwargs)

    return theme.render(
        'topic/datasets.html',
        topic=topic,
        datasets=search.query(topic_search)
    )
开发者ID:odtvince,项目名称:udata,代码行数:13,代码来源:views.py


示例18: reuses

def reuses(topic):
    kwargs = multi_to_dict(request.args)
    kwargs.pop('topic', None)
    topic_search = topic_search_for(topic,
                                    ReuseSearch,
                                    facets=True,
                                    **kwargs)

    return theme.render(
        'topic/reuses.html',
        topic=topic,
        reuses=search.query(topic_search)
    )
开发者ID:odtvince,项目名称:udata,代码行数:13,代码来源:views.py


示例19: get

    def get(self):
        """
        An OEmbed compliant API endpoint

        See: http://oembed.com/

        Support datasets and reuses URLs
        """
        args = oembed_parser.parse_args()
        if args['format'] != 'json':
            api.abort(501, 'Only JSON format is supported')

        url = args['url']

        # Fix flask not detecting URL with https://domain:443/
        if 'https:' in url and ':443/' in url:
            url = url.replace(':443/', '/')

        with current_app.test_request_context(url) as ctx:
            if not ctx.request.endpoint:
                api.abort(404, 'Unknown URL')
            endpoint = ctx.request.endpoint.replace('_redirect', '')
            view_args = ctx.request.view_args

        if endpoint not in self.ROUTES:
            api.abort(404, 'Unknown URL')

        param = self.ROUTES[endpoint]
        item = view_args[param]
        if isinstance(item, Exception):
            raise item
        width = maxwidth = 1000
        height = maxheight = 200
        params = {
            'width': width,
            'height': height,
            'item': item,
            'type': param
        }
        params[param] = item
        html = theme.render('oembed.html', **params)
        return {
            'type': 'rich',
            'version': '1.0',
            'html': html,
            'width': width,
            'height': height,
            'maxwidth': maxwidth,
            'maxheight': maxheight,
        }
开发者ID:opendatateam,项目名称:udata,代码行数:50,代码来源:api.py


示例20: home

def home():
    context = {
        'recent_datasets': Dataset.objects.visible(),
        'recent_reuses': Reuse.objects(featured=True).visible(),
        'last_post': Post.objects.published().first(),
        'rdf_links': [
            (RDF_MIME_TYPES[fmt],
             url_for('site.rdf_catalog_format', format=ext))
            for (fmt, ext) in RDF_EXTENSIONS.items()
        ]
    }
    processor = theme.current.get_processor('home')
    context = processor(context)
    return theme.render('home.html', **context)
开发者ID:odtvince,项目名称:udata,代码行数:14,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_by函数代码示例发布时间:2022-05-27
下一篇:
Python helpers.assert200函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap