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


Python IMasterStore.remove方法代码示例

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


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

示例1: removeAssociation

# 需要导入模块: from lp.services.database.interfaces import IMasterStore [as 别名]
# 或者: from lp.services.database.interfaces.IMasterStore import remove [as 别名]
 def removeAssociation(self, server_url, handle):
     """See `OpenIDStore`."""
     store = IMasterStore(self.Association)
     assoc = store.get(self.Association, (
             server_url.decode('UTF-8'), handle.decode('ASCII')))
     if assoc is None:
         return False
     store.remove(assoc)
     return True
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:11,代码来源:baseopenidstore.py

示例2: __init__

# 需要导入模块: from lp.services.database.interfaces import IMasterStore [as 别名]
# 或者: from lp.services.database.interfaces.IMasterStore import remove [as 别名]
    def __init__(self, *args, **kwargs):
        """Extended version of the SQLObjectBase constructor.

        We force use of the master Store.

        We refetch any parameters from different stores from the
        correct master Store.
        """
        # Make it simple to write dumb-invalidators - initialized
        # _cached_properties to a valid list rather than just-in-time
        # creation.
        self._cached_properties = []
        store = IMasterStore(self.__class__)

        # The constructor will fail if objects from a different Store
        # are passed in. We need to refetch these objects from the correct
        # master Store if necessary so the foreign key references can be
        # constructed.
        # XXX StuartBishop 2009-03-02 bug=336867: We probably want to remove
        # this code - there are enough other places developers have to be
        # aware of the replication # set boundaries. Why should
        # Person(..., account=an_account) work but
        # some_person.account = an_account fail?
        for key, argument in kwargs.items():
            argument = removeSecurityProxy(argument)
            if not isinstance(argument, Storm):
                continue
            argument_store = Store.of(argument)
            if argument_store is not store:
                new_argument = store.find(
                    argument.__class__, id=argument.id).one()
                assert new_argument is not None, (
                    '%s not yet synced to this store' % repr(argument))
                kwargs[key] = new_argument

        store.add(self)
        try:
            self._create(None, **kwargs)
        except:
            store.remove(self)
            raise
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:43,代码来源:sqlbase.py

示例3: getAssociation

# 需要导入模块: from lp.services.database.interfaces import IMasterStore [as 别名]
# 或者: from lp.services.database.interfaces.IMasterStore import remove [as 别名]
    def getAssociation(self, server_url, handle=None):
        """See `OpenIDStore`."""
        store = IMasterStore(self.Association)
        server_url = server_url.decode('UTF-8')
        if handle is None:
            result = store.find(self.Association, server_url=server_url)
        else:
            handle = handle.decode('ASCII')
            result = store.find(
                self.Association, server_url=server_url, handle=handle)

        db_associations = list(result)
        associations = []
        for db_assoc in db_associations:
            assoc = db_assoc.as_association()
            if assoc.getExpiresIn() == 0:
                store.remove(db_assoc)
            else:
                associations.append(assoc)

        if len(associations) == 0:
            return None
        associations.sort(key=attrgetter('issued'))
        return associations[-1]
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:26,代码来源:baseopenidstore.py

示例4: create

# 需要导入模块: from lp.services.database.interfaces import IMasterStore [as 别名]
# 或者: from lp.services.database.interfaces.IMasterStore import remove [as 别名]
    def create(cls, child, parents, arches=(), archindep_archtag=None,
               packagesets=(), rebuild=False, overlays=(),
               overlay_pockets=(), overlay_components=()):
        """Create a new `InitializeDistroSeriesJob`.

        :param child: The child `IDistroSeries` to initialize
        :param parents: An iterable of `IDistroSeries` of parents to
            initialize from.
        :param arches: An iterable of architecture tags which lists the
            architectures to enable in the child.
        :param packagesets: An iterable of `PackageSet` IDs from which to
            copy packages in parents.
        :param rebuild: A boolean to say whether the child should rebuild
            all the copied sources (if True), or to copy the parents'
            binaries (if False).
        :param overlays: An iterable of booleans corresponding exactly to
            each parent in the "parents" parameter.  Each boolean says
            whether this corresponding parent is an overlay for the child
            or not.  An overlay allows the child to use the parent's
            packages for build dependencies, and the overlay_pockets and
            overlay_components parameters dictate from where the
            dependencies may be used in the parent.
        :param overlay_pockets: An iterable of textual pocket names
            corresponding exactly to each parent.  The  name *must* be set
            if the corresponding overlays boolean is True.
        :param overlay_components: An iterable of textual component names
            corresponding exactly to each parent.  The  name *must* be set
            if the corresponding overlays boolean is True.
        """
        store = IMasterStore(DistributionJob)
        # Only one InitializeDistroSeriesJob can be present at a time.
        distribution_job = store.find(
            DistributionJob, DistributionJob.job_id == Job.id,
            DistributionJob.job_type == cls.class_job_type,
            DistributionJob.distroseries_id == child.id).one()
        if distribution_job is not None:
            if distribution_job.job.status == JobStatus.FAILED:
                # Delete the failed job to allow initialization of the series
                # to be rescheduled.
                store.remove(distribution_job)
                store.remove(distribution_job.job)
            elif distribution_job.job.status == JobStatus.COMPLETED:
                raise InitializationCompleted(cls(distribution_job))
            else:
                raise InitializationPending(cls(distribution_job))
        # Schedule the initialization.
        metadata = {
            'parents': parents,
            'arches': arches,
            'archindep_archtag': archindep_archtag,
            'packagesets': packagesets,
            'rebuild': rebuild,
            'overlays': overlays,
            'overlay_pockets': overlay_pockets,
            'overlay_components': overlay_components,
            }
        distribution_job = DistributionJob(
            child.distribution, child, cls.class_job_type, metadata)
        store.add(distribution_job)
        derived_job = cls(distribution_job)
        derived_job.celeryRunOnCommit()
        return derived_job
开发者ID:vitaminmoo,项目名称:unnaturalcode,代码行数:64,代码来源:initializedistroseriesjob.py

示例5: TestBugSummary

# 需要导入模块: from lp.services.database.interfaces import IMasterStore [as 别名]
# 或者: from lp.services.database.interfaces.IMasterStore import remove [as 别名]
class TestBugSummary(TestCaseWithFactory):

    layer = LaunchpadZopelessLayer

    def setUp(self):
        super(TestBugSummary, self).setUp()

        # Some things we are testing are impossible as mere mortals,
        # but might happen from the SQL command line.
        switch_dbuser('testadmin')

        self.store = IMasterStore(BugSummary)

    def getCount(self, person, **kw_find_expr):
        self._maybe_rollup()
        store = self.store
        user_with, user_where = get_bugsummary_filter_for_user(person)
        if user_with:
            store = store.with_(user_with)
        summaries = store.find(BugSummary, *user_where, **kw_find_expr)
        # Note that if there a 0 records found, sum() returns None, but
        # we prefer to return 0 here.
        return summaries.sum(BugSummary.count) or 0

    def assertCount(self, count, user=None, **kw_find_expr):
        self.assertEqual(count, self.getCount(user, **kw_find_expr))

    def _maybe_rollup(self):
        """Rollup the journal if the class is testing the rollup case."""
        # The base class does not rollup the journal, see
        # TestBugSummaryRolledUp which does.
        pass

    def test_providesInterface(self):
        bug_summary = self.store.find(BugSummary)[0]
        self.assertTrue(IBugSummary.providedBy(bug_summary))

    def test_addTag(self):
        tag = u'pustular'

        # Ensure nothing using our tag yet.
        self.assertCount(0, tag=tag)

        product = self.factory.makeProduct()

        for count in range(3):
            bug = self.factory.makeBug(target=product)
            bug_tag = BugTag(bug=bug, tag=tag)
            self.store.add(bug_tag)

        # Number of tagged tasks for a particular product
        self.assertCount(3, product=product, tag=tag)

        # There should be no other BugSummary rows.
        self.assertCount(3, tag=tag)

    def test_changeTag(self):
        old_tag = u'pustular'
        new_tag = u'flatulent'

        # Ensure nothing using our tags yet.
        self.assertCount(0, tag=old_tag)
        self.assertCount(0, tag=new_tag)

        product = self.factory.makeProduct()

        for count in range(3):
            bug = self.factory.makeBug(target=product)
            bug_tag = BugTag(bug=bug, tag=old_tag)
            self.store.add(bug_tag)

        # Number of tagged tasks for a particular product
        self.assertCount(3, product=product, tag=old_tag)

        for count in reversed(range(3)):
            bug_tag = self.store.find(BugTag, tag=old_tag).any()
            bug_tag.tag = new_tag

            self.assertCount(count, product=product, tag=old_tag)
            self.assertCount(3 - count, product=product, tag=new_tag)

        # There should be no other BugSummary rows.
        self.assertCount(0, tag=old_tag)
        self.assertCount(3, tag=new_tag)

    def test_removeTag(self):
        tag = u'pustular'

        # Ensure nothing using our tags yet.
        self.assertCount(0, tag=tag)

        product = self.factory.makeProduct()

        for count in range(3):
            bug = self.factory.makeBug(target=product)
            bug_tag = BugTag(bug=bug, tag=tag)
            self.store.add(bug_tag)

        # Number of tagged tasks for a particular product
        self.assertCount(3, product=product, tag=tag)
#.........这里部分代码省略.........
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:103,代码来源:test_bugsummary.py


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