本文整理汇总了Python中tardis.tardis_portal.models.Schema.getNamespaces方法的典型用法代码示例。如果您正苦于以下问题:Python Schema.getNamespaces方法的具体用法?Python Schema.getNamespaces怎么用?Python Schema.getNamespaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tardis.tardis_portal.models.Schema
的用法示例。
在下文中一共展示了Schema.getNamespaces方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getFilteredExperiments
# 需要导入模块: from tardis.tardis_portal.models import Schema [as 别名]
# 或者: from tardis.tardis_portal.models.Schema import getNamespaces [as 别名]
def __getFilteredExperiments(request, searchFilterData):
"""Filter the list of experiments using the cleaned up searchFilterData.
Arguments:
request -- the HTTP request
searchFilterData -- the cleaned up search experiment form data
Returns:
A list of experiments as a result of the query or None if the provided
search request is invalid
"""
experiments = authz.get_accessible_experiments(request)
if experiments is None:
return []
# search for the default experiment fields
if searchFilterData['title'] != '':
experiments = \
experiments.filter(title__icontains=searchFilterData['title'])
if searchFilterData['description'] != '':
experiments = \
experiments.filter(
description__icontains=searchFilterData['description'])
if searchFilterData['institutionName'] != '':
experiments = experiments.filter(
institution_name__icontains=searchFilterData['institutionName'])
if searchFilterData['creator'] != '':
experiments = experiments.filter(
experimentauthor__author__icontains=searchFilterData['creator'])
date = searchFilterData['date']
if date is not None:
experiments = \
experiments.filter(start_time__lt=date, end_time__gt=date)
# get all the experiment parameters
exp_schema_namespaces = Schema.getNamespaces(Schema.EXPERIMENT)
parameters = ParameterName.objects.filter(
schema__namespace__in=exp_schema_namespaces, is_searchable=True)
experiments = __filterParameters(
parameters, experiments,
searchFilterData, 'experimentparameterset__experimentparameter')
# let's sort it in the end
experiments = experiments.order_by('title')
return experiments
示例2: __getFilteredDatafiles
# 需要导入模块: from tardis.tardis_portal.models import Schema [as 别名]
# 或者: from tardis.tardis_portal.models.Schema import getNamespaces [as 别名]
def __getFilteredDatafiles(request, searchQueryType, searchFilterData):
"""Filter the list of datafiles for the provided searchQueryType using the
cleaned up searchFilterData.
Arguments:
request -- the HTTP request
searchQueryType -- the type of query, 'mx' or 'saxs'
searchFilterData -- the cleaned up search form data
Returns:
A list of datafiles as a result of the query or None if the provided search
request is invalid
"""
datafile_results = authz.get_accessible_datafiles_for_user(request)
logger.info('__getFilteredDatafiles: searchFilterData {0}'.
format(searchFilterData))
# there's no need to do any filtering if we didn't find any
# datafiles that the user has access to
if not datafile_results:
logger.info("""__getFilteredDatafiles: user {0} doesn\'t have
access to any experiments""".format(request.user))
return datafile_results
q = {
'datafileparameterset__datafileparameter__name__schema__namespace__in':
Schema.getNamespaces(Schema.DATAFILE, searchQueryType)
}
datafile_results = datafile_results.filter(**q).distinct()
# if filename is searchable which i think will always be the case...
if searchFilterData['filename'] != '':
datafile_results = \
datafile_results.filter(
filename__icontains=searchFilterData['filename'])
# TODO: might need to cache the result of this later on
# get all the datafile parameters for the given schema
parameters = [p for p in
ParameterName.objects.filter(
schema__namespace__in=Schema.getNamespaces(
Schema.DATAFILE, searchQueryType))]
datafile_results = __filterParameters(
parameters, datafile_results,
searchFilterData, 'datafileparameterset__datafileparameter')
# get all the dataset parameters for given schema
parameters = [p for p in
ParameterName.objects.filter(
schema__namespace__in=Schema.getNamespaces(
Schema.DATASET, searchQueryType))]
datafile_results = __filterParameters(
parameters, datafile_results,
searchFilterData, 'dataset__datasetparameterset__datasetparameter')
# let's sort it in the end
if datafile_results:
datafile_results = datafile_results.order_by('filename')
logger.debug("results: {0}".format(datafile_results))
return datafile_results