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


Python theme.render函数代码示例

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


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


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