本文整理匯總了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()