本文整理汇总了Python中udata.utils.multi_to_dict函数的典型用法代码示例。如果您正苦于以下问题:Python multi_to_dict函数的具体用法?Python multi_to_dict怎么用?Python multi_to_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了multi_to_dict函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
def search():
datasets, organizations, reuses = multiquery(
SearchQuery(DatasetSearch, **multi_to_dict(request.args)),
SearchQuery(OrganizationSearch, **multi_to_dict(request.args)),
SearchQuery(ReuseSearch, **multi_to_dict(request.args)),
)
return render("search.html", datasets=datasets, organizations=organizations, reuses=reuses)
示例2: rdf_catalog_format
def rdf_catalog_format(format):
params = multi_to_dict(request.args)
page = int(params.get('page', 1))
page_size = int(params.get('page_size', 100))
datasets = Dataset.objects.visible().paginate(page, page_size)
catalog = build_catalog(current_site, datasets, format=format)
return graph_response(catalog, format)
示例3: redirect_to_lang
def redirect_to_lang(*args, **kwargs):
'''Redirect non lang-prefixed urls to default language.'''
endpoint = request.endpoint.replace('_redirect', '')
kwargs = multi_to_dict(request.args)
kwargs.update(request.view_args)
kwargs['lang_code'] = default_lang
return redirect(url_for(endpoint, **kwargs))
示例4: redirect_to_unlocalized
def redirect_to_unlocalized(*args, **kwargs):
'''Redirect lang-prefixed urls to no prefixed URL.'''
endpoint = request.endpoint.replace('_redirect', '')
kwargs = multi_to_dict(request.args)
kwargs.update(request.view_args)
kwargs.pop('lang_code', None)
return redirect(url_for(endpoint, **kwargs))
示例5: get
def get(self):
"""List all objects"""
if self.search_adapter:
objects = search.query(self.search_adapter, **multi_to_dict(request.args))
else:
objects = list(self.model.objects)
return marshal_page(objects, self.fields)
示例6: redirect_to_lang
def redirect_to_lang(*args, **kwargs):
"""Redirect non lang-prefixed urls to default language."""
endpoint = request.endpoint.replace("_redirect", "")
kwargs = multi_to_dict(request.args)
kwargs.update(request.view_args)
kwargs["lang_code"] = default_lang
return redirect(url_for(endpoint, **kwargs))
示例7: 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)))
示例8: get
def get(self):
if self.search_adapter:
result = search.query(self.search_adapter, **multi_to_dict(request.args))
objects = result.get_objects()
else:
objects = list(self.model.objects)
return marshal(objects, self.fields)
示例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()
)
示例10: 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()
)
示例11: organizations_csv
def organizations_csv():
params = multi_to_dict(request.args)
# redirect to EXPORT_CSV dataset if feature is enabled and no filter is set
exported_models = current_app.config.get('EXPORT_CSV_MODELS', [])
if not params and 'organization' in exported_models:
return redirect(get_export_url('organization'))
params['facets'] = False
organizations = search.iter(Organization, **params)
return csv.stream(OrganizationCsvAdapter(organizations), 'organizations')
示例12: reuses_csv
def reuses_csv():
params = multi_to_dict(request.args)
# redirect to EXPORT_CSV dataset if feature is enabled and no filter is set
exported_models = current_app.config.get('EXPORT_CSV_MODELS', [])
if not params and 'reuse' in exported_models:
return redirect(get_export_url('reuse'))
params['facets'] = False
reuses = search.iter(Reuse, **params)
return csv.stream(ReuseCsvAdapter(reuses), 'reuses')
示例13: datasets_csv
def datasets_csv():
params = multi_to_dict(request.args)
# redirect to EXPORT_CSV dataset if feature is enabled and no filter is set
exported_models = current_app.config.get('EXPORT_CSV_MODELS', [])
if not params and 'dataset' in exported_models:
return redirect(get_export_url('dataset'))
params['facets'] = False
datasets = search.iter(Dataset, **params)
adapter = csv.get_adapter(Dataset)
return csv.stream(adapter(datasets), 'datasets')
示例14: 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)
)
示例15: 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)
)