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


Python Dataset.by_id方法代码示例

本文整理汇总了Python中openspending.model.Dataset.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.by_id方法的具体用法?Python Dataset.by_id怎么用?Python Dataset.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openspending.model.Dataset的用法示例。


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

示例1: create_view

# 需要导入模块: from openspending.model import Dataset [as 别名]
# 或者: from openspending.model.Dataset import by_id [as 别名]
    def create_view(self, cls, add_filters, name, label, dimension,
                    breakdown=None, view_filters={}):
        '''\
        Create a view. The view will be computed when you call
        :meth:`finalize`.

        ``cls``
            A model class (inheriting from :class:`openspending.model.Base`)
        ``add_filters``
            A :term:`mongodb query spec` used as a query to select the
            instances of *cls* that will be used for the view.
        ``name``
            A name for the view. This name must be unique for all views
            for *cls* in an Open Spending site.
        ``label``
            A label that can be displayed to the user.
        ``dimensions``
            The dimensions that will be used to compute the view
        ``breakdown``
            ...
        ``view_filters``
            ...

        Returns: A :class:`openspending.lib.views.View` object.
        '''
        log.debug("pre-aggregating view %s on %r where %r",
                  name, cls, view_filters)
        view = View(self.dataset, name, label, dimension,
                    breakdown, cuts=view_filters)
        view.apply_to(cls, add_filters)
        view.compute()
        Dataset.c.update({'name': self.dataset.name},
                         {'$set': {'cubes': self.dataset.get('cubes', {})}})
        self.dataset = Dataset.by_id(self.dataset.name)
        return view
开发者ID:pombredanne,项目名称:openspending.etl,代码行数:37,代码来源:loader.py

示例2: report

# 需要导入模块: from openspending.model import Dataset [as 别名]
# 或者: from openspending.model.Dataset import by_id [as 别名]
def report():
    dataset_id = request.args.get("id", None)
    if not dataset_id:
        raise
    dataset = Dataset.by_id(dataset_id)
    if not dataset:
        raise
    lr = LoadReport(dataset)
    return Response(lr.get_output(),
                mimetype='application/zip',
                headers={'Content-Disposition':'attachment;filename=%s.zip'%dataset.name})
开发者ID:nathanhilbert,项目名称:FPA_Core,代码行数:13,代码来源:admin.py

示例3: reload_all

# 需要导入模块: from openspending.model import Dataset [as 别名]
# 或者: from openspending.model.Dataset import by_id [as 别名]
    def reload_all(**args):
        """Reload all sources with mapping.  This will take a while"""

        datasets = Dataset.all().all()
        ids = []
        for dataset in datasets:
            ids.append(dataset.id)

        total = 0
        ran = 0

        for id in ids:
            dataset = Dataset.by_id(id)
            total +=1
            #has mapping and source
            if dataset.mapping and dataset.source:
                print "working on ", dataset
                load_source(dataset.source.id)
                ran +=1

        print "Ran", ran, "out of", total
开发者ID:nathanhilbert,项目名称:FPA_Core,代码行数:23,代码来源:importer.py


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