本文整理匯總了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
示例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
示例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]
示例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
示例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)
#.........這裏部分代碼省略.........