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


Python Schema.getNamespaces方法代码示例

本文整理汇总了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
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:56,代码来源:utils.py

示例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
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:67,代码来源:utils.py


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