本文整理汇总了Python中lp.services.database.interfaces.IStore.add方法的典型用法代码示例。如果您正苦于以下问题:Python IStore.add方法的具体用法?Python IStore.add怎么用?Python IStore.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lp.services.database.interfaces.IStore
的用法示例。
在下文中一共展示了IStore.add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import add [as 别名]
def create(self, regexp, comment=None, admin=None):
"""See `INameBlacklistSet`."""
nameblacklist = NameBlacklist()
nameblacklist.regexp = regexp
nameblacklist.comment = comment
nameblacklist.admin = admin
store = IStore(NameBlacklist)
store.add(nameblacklist)
return nameblacklist
示例2: makeJob
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import add [as 别名]
def makeJob(self):
"""See `IBuildFarmJobOld`."""
store = IStore(BranchJob)
# Pass public HTTP URL for the branch.
metadata = {
'branch_url': self.branch.composePublicURL(),
'build_id': self.id,
}
branch_job = BranchJob(
self.branch, BranchJobType.TRANSLATION_TEMPLATES_BUILD, metadata)
store.add(branch_job)
return TranslationTemplatesBuildJob(branch_job)
示例3: create_missing_pofiletranslators
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import add [as 别名]
def create_missing_pofiletranslators(logger, pofile, pofts, contribs):
"""Create `POFileTranslator` records that were missing."""
shortage = set(contribs) - pofts
if len(shortage) == 0:
return
logger.debug(
"Adding %d POFileTranslator(s) for %s.",
len(shortage), pofile.title)
store = IStore(pofile)
for missing_contributor in shortage:
store.add(POFileTranslator(
pofile=pofile, personID=missing_contributor,
date_last_touched=contribs[missing_contributor]))
示例4: addActivity
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import add [as 别名]
def addActivity(self, result=None, message=None, oops_id=None):
"""See `IBugWatch`."""
activity = BugWatchActivity()
activity.bug_watch = self
if result is None:
# If no result is passed we assume that the activity
# succeded and set the result field accordingly.
activity.result = BugWatchActivityStatus.SYNC_SUCCEEDED
else:
activity.result = result
if message is not None:
activity.message = unicode(message)
if oops_id is not None:
activity.oops_id = unicode(oops_id)
store = IStore(BugWatchActivity)
store.add(activity)
示例5: _set_tags
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import add [as 别名]
def _set_tags(self, tags):
"""Update the tags to filter on.
The tags can be qualified with a leading hyphen, and can be bundled in
any iterable.
If they are passed within a `searchbuilder.any` or `searchbuilder.all`
object, the `find_all_tags` attribute will be updated to match.
Wildcard tags - `*` and `-*` - can be given too, and will update
`include_any_tags` and `exclude_any_tags`.
"""
# Deal with searchbuilder terms.
if isinstance(tags, searchbuilder.all):
self.find_all_tags = True
tags = frozenset(tags.query_values)
elif isinstance(tags, searchbuilder.any):
self.find_all_tags = False
tags = frozenset(tags.query_values)
else:
# Leave find_all_tags unchanged.
tags = frozenset(tags)
wildcards = frozenset((u"*", u"-*")).intersection(tags)
# Set wildcards.
self.include_any_tags = "*" in wildcards
self.exclude_any_tags = "-*" in wildcards
# Deal with other tags.
tags = tags - wildcards
store = IStore(BugSubscriptionFilterTag)
current_tag_filters = dict(
(tag_filter.qualified_tag, tag_filter)
for tag_filter in store.find(
BugSubscriptionFilterTag,
BugSubscriptionFilterTag.filter == self))
# Remove unused tags.
for tag in set(current_tag_filters).difference(tags):
tag_filter = current_tag_filters.pop(tag)
store.remove(tag_filter)
# Add additional tags.
for tag in tags.difference(current_tag_filters):
tag_filter = BugSubscriptionFilterTag()
tag_filter.filter = self
tag_filter.include = not tag.startswith("-")
tag_filter.tag = tag.lstrip("-")
store.add(tag_filter)
示例6: _set_collection
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import add [as 别名]
def _set_collection(self, cls, enum, attribute, current_set, desired_set):
desired_set = frozenset(desired_set)
if desired_set == frozenset(enum.items):
# Setting all is the same as setting none, and setting none is
# cheaper for reading and storage.
desired_set = frozenset()
# Add missing.
store = IStore(cls)
for kind in desired_set.difference(current_set):
bsf = cls()
bsf.filter = self
setattr(bsf, attribute, kind)
store.add(bsf)
# Remove unused.
kind = getattr(cls, attribute)
store.find(
cls, cls.filter == self, kind.is_in(
current_set.difference(desired_set))).remove()