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


Python Store.of方法代码示例

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


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

示例1: test_getByBuildFarmJobs

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
 def test_getByBuildFarmJobs(self):
     sprbs = [self.makeSourcePackageRecipeBuild() for i in range(10)]
     Store.of(sprbs[0]).flush()
     self.assertContentEqual(
         sprbs,
         SourcePackageRecipeBuild.getByBuildFarmJobs(
             [sprb.build_farm_job for sprb in sprbs]))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:9,代码来源:test_sourcepackagerecipebuild.py

示例2: bequeathe_flags

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
def bequeathe_flags(source_message, target_message, incumbents=None):
    """Destroy `source_message`, leaving flags to `target_message`.

    If `source_message` holds the is_current_ubuntu flag, and there are no
    `incumbents` that hold the same flag, then `target_message` inherits
    it.  Similar for the is_current_upstream flag.
    """
    sacrifice_flags(source_message, incumbents)

    if (source_message.is_current_ubuntu and
        not target_message.is_current_ubuntu):
        # Transfer is_current_ubuntu flag.
        source_message.is_current_ubuntu = False
        target_message.is_current_ubuntu = True
        Store.of(source_message).add_flush_order(
            source_message, target_message)

    if (source_message.is_current_upstream and
        not target_message.is_current_upstream):
        # Transfer is_current_upstream flag.
        source_message.is_current_upstream = False
        target_message.is_current_upstream = True
        Store.of(source_message).add_flush_order(
            source_message, target_message)

    source_message.destroySelf()
开发者ID:vitaminmoo,项目名称:unnaturalcode,代码行数:28,代码来源:translationmerger.py

示例3: delete

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
 def delete(self):
     """Deletes the exercise, providing it has no associated worksheets."""
     if (self.worksheet_exercises.count() > 0):
         raise IntegrityError()
     for suite in self.test_suites:
         suite.delete()
     Store.of(self).remove(self)
开发者ID:dcoles,项目名称:ivle,代码行数:9,代码来源:database.py

示例4: take

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
    def take(self, count):
        """Take some amount of parts from this pile and return the object
        representing this amount. Everything gets copied over."""

        assert count > 0
        assert count <= self.count

        if count == self.count:
            return self

        take = Part()
        take.count = count
        self.count -= count

        take.source = self.source
        take.date = self.date
        take.price = self.price
        take.vat = self.vat
        take.part_type = self.part_type
        take.assignment = self.assignment
        take.history = self.history
        take.soldered = self.soldered
        take.usable = self.usable
        Store.of(self).add(take)

        return take
开发者ID:MarSik,项目名称:elshelves,代码行数:28,代码来源:model.py

示例5: test_generateEmail_with_null_fields

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
 def test_generateEmail_with_null_fields(self):
     """GenerateEmail works when many fields are NULL."""
     person = self.factory.makePerson(name='person')
     cake = self.factory.makeSourcePackageRecipe(
         name=u'recipe', owner=person)
     pantry_owner = self.factory.makePerson(name='archiveowner')
     pantry = self.factory.makeArchive(name='ppa', owner=pantry_owner)
     secret = self.factory.makeDistroSeries(name=u'distroseries')
     build = self.factory.makeSourcePackageRecipeBuild(
         recipe=cake, distroseries=secret, archive=pantry,
         status=BuildStatus.SUPERSEDED)
     Store.of(build).flush()
     ctrl = self.makeStatusEmail(build)
     self.assertEqual(
         u'[recipe build #%d] of ~person recipe in distroseries: '
         'Build for superseded Source' % (build.id), ctrl.subject)
     body, footer = ctrl.body.split('\n-- \n')
     self.assertEqual(superseded_body, body)
     build_url = canonical_url(build)
     self.assertEqual(
         '%s\nYou are the requester of the build.\n' % build_url, footer)
     self.assertEqual(
         config.canonical.noreply_from_address, ctrl.from_addr)
     self.assertEqual(
         'Requester', ctrl.headers['X-Launchpad-Message-Rationale'])
     self.assertEqual(
         'recipe-build-status',
         ctrl.headers['X-Launchpad-Notification-Type'])
     self.assertEqual(
         'SUPERSEDED', ctrl.headers['X-Launchpad-Build-State'])
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:32,代码来源:test_sourcepackagerecipebuild.py

示例6: test_binary_builds

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
 def test_binary_builds(self):
     """The binary_builds property should be populated automatically."""
     spb = self.factory.makeSourcePackageRecipeBuild()
     multiverse = self.factory.makeComponent(name='multiverse')
     spr = self.factory.makeSourcePackageRelease(
         source_package_recipe_build=spb, component=multiverse)
     self.assertEqual([], list(spb.binary_builds))
     binary = self.factory.makeBinaryPackageBuild(spr)
     self.factory.makeBinaryPackageBuild()
     Store.of(binary).flush()
     self.assertEqual([binary], list(spb.binary_builds))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:13,代码来源:test_sourcepackagerecipebuild.py

示例7: test_builder_history

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
 def test_builder_history(self):
     build = self.makeRecipeBuild()
     Store.of(build).flush()
     build_url = canonical_url(build)
     build.updateStatus(
         BuildStatus.FULLYBUILT, builder=self.factory.makeBuilder())
     browser = self.getViewBrowser(build.builder, '+history')
     self.assertTextMatchesExpressionIgnoreWhitespace(
          'Build history.*~chef/chocolate/cake recipe build',
          extract_text(find_main_content(browser.contents)))
     self.assertEqual(build_url,
             browser.getLink('~chef/chocolate/cake recipe build').url)
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:14,代码来源:test_sourcepackagerecipebuild.py

示例8: test_update_existing_record

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
    def test_update_existing_record(self):
        '''Existing records should be updated.'''
        handler = self.handler()
        _video = handler(self.filename)
        videos = Store.of(_video).find(models.VideoFile,
            models.VideoFile.filename == self.filename)
        self.assertEqual(videos.count(), 1)

        _video = handler(self.filename)
        videos = Store.of(_video).find(models.VideoFile,
            models.VideoFile.filename == self.filename)
        self.assertEqual(videos.count(), 1)
开发者ID:tiwilliam,项目名称:entertainer,代码行数:14,代码来源:test_filehandlers.py

示例9: clone_worksheets

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
 def clone_worksheets(self, source):
     """Clone all worksheets from the specified source to this offering."""
     import ivle.worksheet.utils
     for worksheet in source.worksheets:
         newws = Worksheet()
         newws.seq_no = worksheet.seq_no
         newws.identifier = worksheet.identifier
         newws.name = worksheet.name
         newws.assessable = worksheet.assessable
         newws.published = worksheet.published
         newws.data = worksheet.data
         newws.format = worksheet.format
         newws.offering = self
         Store.of(self).add(newws)
         ivle.worksheet.utils.update_exerciselist(newws)
开发者ID:dcoles,项目名称:ivle,代码行数:17,代码来源:database.py

示例10: new

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
    def new(cls, distribution, sourcepackagename,
            is_upstream_link_allowed=False):
        """Create a new DSP with the given parameters.

        Caches the `(distro_id, spn_id) --> dsp_id` mapping.
        """
        dsp = DistributionSourcePackageInDatabase()
        dsp.distribution = distribution
        dsp.sourcepackagename = sourcepackagename
        dsp.is_upstream_link_allowed = is_upstream_link_allowed
        Store.of(distribution).add(dsp)
        Store.of(distribution).flush()
        dsp_cache_key = distribution.id, sourcepackagename.id
        cls._cache[dsp_cache_key] = dsp.id
        return dsp
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:17,代码来源:distributionsourcepackage.py

示例11: submit

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
    def submit(self, principal, path, revision, who, late=False):
        """Submit a Subversion path and revision to a project.

        @param principal: The owner of the Subversion repository, and the
                          entity on behalf of whom the submission is being made
        @param path: A path within that repository to submit.
        @param revision: The revision of that path to submit.
        @param who: The user who is actually making the submission.
        @param late: If True, will not raise a DeadlinePassed exception even
            after the deadline. (Default False.)
        """

        if not self.can_submit(principal, who, late=late):
            raise DeadlinePassed()

        a = Assessed.get(Store.of(self), principal, self)
        ps = ProjectSubmission()
        # Raise SubmissionError if the path is illegal
        ps.path = ProjectSubmission.test_and_normalise_path(path)
        ps.revision = revision
        ps.date_submitted = datetime.datetime.now()
        ps.assessed = a
        ps.submitter = who

        return ps
开发者ID:dcoles,项目名称:ivle,代码行数:27,代码来源:database.py

示例12: specifications

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
 def specifications(self, user, sort=None, quantity=None, filter=None,
                    need_people=False, need_branches=False,
                    need_workitems=False):
     """See IHasSpecifications."""
     # need_* is provided only for interface compatibility and
     # need_*=True is not implemented.
     if filter is None:
         filter = set([SpecificationFilter.ACCEPTED])
     tables, query = self.spec_filter_clause(user, filter)
     # import here to avoid circular deps
     from lp.blueprints.model.specification import Specification
     results = Store.of(self).using(*tables).find(Specification, *query)
     if sort == SpecificationSort.DATE:
         order = (Desc(SprintSpecification.date_created), Specification.id)
         distinct = [SprintSpecification.date_created, Specification.id]
         # we need to establish if the listing will show specs that have
         # been decided only, or will include proposed specs.
         if (SpecificationFilter.ALL not in filter and
             SpecificationFilter.PROPOSED not in filter):
             # this will show only decided specs so use the date the spec
             # was accepted or declined for the sprint
             order = (Desc(SprintSpecification.date_decided),) + order
             distinct = [SprintSpecification.date_decided] + distinct
         results = results.order_by(*order)
     else:
         assert sort is None or sort == SpecificationSort.PRIORITY
         # fall back to default, which is priority, descending.
         distinct = True
     if quantity is not None:
         results = results[:quantity]
     return results.config(distinct=distinct)
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:33,代码来源:sprint.py

示例13: get

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
    def get(cls, distribution, sourcepackagename):
        """Get a DSP given distribution and source package name.

        Attempts to use a cached `(distro_id, spn_id) --> dsp_id` mapping to
        avoid hitting the database.
        """
        # Check for a cached mapping from (distro_id, spn_id) to dsp_id.
        dsp_cache_key = distribution.id, sourcepackagename.id
        dsp_id = cls._cache.get(dsp_cache_key)
        # If not, fetch from the database.
        if dsp_id is None:
            return cls.getDirect(distribution, sourcepackagename)
        # Try store.get(), allowing Storm to answer from cache if it can.
        store = Store.of(distribution)
        dsp = store.get(DistributionSourcePackageInDatabase, dsp_id)
        # If it's not found, query the database; the mapping might be stale.
        if dsp is None:
            return cls.getDirect(distribution, sourcepackagename)
        # Check that the mapping in the cache was correct.
        if distribution.id != dsp.distribution_id:
            return cls.getDirect(distribution, sourcepackagename)
        if sourcepackagename.id != dsp.sourcepackagename_id:
            return cls.getDirect(distribution, sourcepackagename)
        # Cache hit, phew.
        return dsp
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:27,代码来源:distributionsourcepackage.py

示例14: createRecipeBuildWithBuilder

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
 def createRecipeBuildWithBuilder(self, private_branch=False,
                                  builder=None):
     if builder is None:
         builder = self.factory.makeBuilder()
     branch2 = self.factory.makeAnyBranch()
     branch1 = self.factory.makeAnyBranch()
     build = self.factory.makeSourcePackageRecipeBuild(
         recipe=self.factory.makeSourcePackageRecipe(
             branches=[branch1, branch2]))
     if private_branch:
         with celebrity_logged_in('admin'):
             branch1.setPrivate(
                 True, getUtility(IPersonSet).getByEmail(ADMIN_EMAIL))
     Store.of(build).flush()
     self.markAsBuilt(build, builder)
     return build
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:18,代码来源:test_builder_views.py

示例15: getSpecifications

# 需要导入模块: from storm.locals import Store [as 别名]
# 或者: from storm.locals.Store import of [as 别名]
    def getSpecifications(self, user):
        """See `IMilestoneData`"""
        from lp.registry.model.person import Person
        origin = [Specification]
        product_origin, clauses = get_specification_active_product_filter(
            self)
        origin.extend(product_origin)
        clauses.extend(get_specification_privacy_filter(user))
        origin.append(LeftJoin(Person, Specification._assigneeID == Person.id))
        milestones = self._milestone_ids_expr(user)

        results = Store.of(self.target).using(*origin).find(
            (Specification, Person),
            Specification.id.is_in(
                Union(
                    Select(
                        Specification.id, tables=[Specification],
                        where=(Specification.milestoneID.is_in(milestones))),
                    Select(
                        SpecificationWorkItem.specification_id,
                        tables=[SpecificationWorkItem],
                        where=And(
                            SpecificationWorkItem.milestone_id.is_in(
                                milestones),
                            SpecificationWorkItem.deleted == False)),
                    all=True)),
            *clauses)
        ordered_results = results.order_by(
            Desc(Specification.priority), Specification.definition_status,
            Specification.implementation_status, Specification.title)
        ordered_results.config(distinct=True)
        return DecoratedResultSet(ordered_results, itemgetter(0))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:34,代码来源:milestone.py


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