本文整理汇总了Python中axiom.substore.SubStore.open方法的典型用法代码示例。如果您正苦于以下问题:Python SubStore.open方法的具体用法?Python SubStore.open怎么用?Python SubStore.open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类axiom.substore.SubStore
的用法示例。
在下文中一共展示了SubStore.open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: insertUserStore
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import open [as 别名]
def insertUserStore(siteStore, userStorePath):
"""
Move the SubStore at the indicated location into the given site store's
directory and then hook it up to the site store's authentication database.
@type siteStore: C{Store}
@type userStorePath: C{FilePath}
"""
# The following may, but does not need to be in a transaction, because it
# is merely an attempt to guess a reasonable filesystem name to use for
# this avatar. The user store being operated on is expected to be used
# exclusively by this process.
ls = siteStore.findUnique(LoginSystem)
unattachedSubStore = Store(userStorePath)
for lm in unattachedSubStore.query(LoginMethod,
LoginMethod.account == unattachedSubStore.findUnique(LoginAccount),
sort=LoginMethod.internal.descending):
if ls.accountByAddress(lm.localpart, lm.domain) is None:
localpart, domain = lm.localpart, lm.domain
break
else:
raise AllNamesConflict()
unattachedSubStore.close()
insertLocation = siteStore.newFilePath('account', domain, localpart + '.axiom')
insertParentLoc = insertLocation.parent()
if not insertParentLoc.exists():
insertParentLoc.makedirs()
if insertLocation.exists():
raise DatabaseDirectoryConflict()
userStorePath.moveTo(insertLocation)
ss = SubStore(store=siteStore, storepath=insertLocation)
attachedStore = ss.open()
# migrateUp() manages its own transactions because it interacts with two
# different stores.
attachedStore.findUnique(LoginAccount).migrateUp()