當前位置: 首頁>>代碼示例>>Python>>正文


Python substore.SubStore類代碼示例

本文整理匯總了Python中axiom.substore.SubStore的典型用法代碼示例。如果您正苦於以下問題:Python SubStore類的具體用法?Python SubStore怎麽用?Python SubStore使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SubStore類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_upgradeStoreRecursing

    def test_upgradeStoreRecursing(self):
        """
        L{Upgrade} upgrades L{Item}s in substores.
        """
        choose(oldapp)

        ss1 = SubStore.createNew(self.store, ['a'])
        ss2 = SubStore.createNew(self.store, ['b'])

        swordIDs = [
            (ss1.storeID, oldapp.Sword(store=ss1.open(), name='foo').storeID),
            (ss2.storeID, oldapp.Sword(store=ss2.open(), name='bar').storeID)]

        del ss1, ss2
        self.store.close()

        choose(deleteswordapp)
        self.store = store.Store(self.dbdir)

        cmd = Upgrade()
        cmd.parent = CommandStub(self.store, 'upgrade')

        callWithStdoutRedirect(cmd.parseOptions, [])

        for (ssid, swordID) in swordIDs:
            self.assertRaises(
                KeyError,
                self.store.getItemByID(ssid).open().getItemByID, swordID)
開發者ID:perkinslr,項目名稱:axiom-py3,代碼行數:28,代碼來源:test_upgrading.py

示例2: setUp

    def setUp(self):
        """
        Set up stores and an offering.
        """
        store = Store(dbdir=self.mktemp())
        appStore1 = SubStore.createNew(store, ("app", "test1.axiom"))
        appStore2 = SubStore.createNew(store, ("app", "test2.axiom"))
        self.firstOffering = Offering(u'first offering', None, None, None, None,
                                      None, [])
        firstInstalledOffering = InstalledOffering(
            store=store, application=appStore1,
            offeringName=self.firstOffering.name)
        ss1 = appStore1.open()
        self.installApp(ss1)
        # (bypass Item.__setattr__)
        object.__setattr__(
            firstInstalledOffering, 'getOffering',
            lambda: self.firstOffering)

        secondOffering = Offering(u'second offering', None, None, None, None,
                                  None, [])
        secondInstalledOffering = InstalledOffering(
            store=store, application=appStore2,
            offeringName=secondOffering.name)
        # (bypass Item.__setattr__)
        object.__setattr__(secondInstalledOffering, 'getOffering',
                           lambda: secondOffering)

        self.fragment = _OfferingsFragment(FrontPage(store=store))
開發者ID:rcarmo,項目名稱:divmod.org,代碼行數:29,代碼來源:test_publicweb.py

示例3: testAvatarStoreState

    def testAvatarStoreState(self):
        """
        You can only pass an 'avatars' argument if it doesn't already have an
        account in it.  Some accounts want to have their stores in slightly odd
        places (like offering.py) but you can't have two accounts added which
        both point to the same store.
        """
        dbdir = FilePath(self.mktemp())
        s = Store(dbdir)
        ls = userbase.LoginSystem(store=s)
        dependency.installOn(ls, s)
        acc = ls.addAccount('alice', 'dom.ain', 'password')

        # this is allowed, if weird
        unrelatedAccount = ls.addAccount(
            'elseice', 'dom.ain', 'password',
            avatars=SubStore.createNew(s, ('crazy', 'what')))

        # this is not allowed.
        self.assertRaises(errors.DuplicateUniqueItem,
                          ls.addAccount,
                          'bob', 'ain.dom', 'xpassword',
                          avatars=acc.avatars)

        # Make sure that our stupid call to addAccount did not corrupt
        # anything, because we are stupid
        self.assertEqual(acc.avatars.open().query(userbase.LoginAccount).count(), 1)
開發者ID:perkinslr,項目名稱:axiom-py3,代碼行數:27,代碼來源:test_userbase.py

示例4: test_subSchedule

 def test_subSchedule(self):
     """
     The same as test_schedule, except using a subscheduler.
     """
     subst = SubStore.createNew(self.store, ['scheduler_test'])
     substore = subst.open()
     subscheduler = IScheduler(substore)
     return self._testSchedule(subscheduler)
開發者ID:ldanielburr,項目名稱:axiom,代碼行數:8,代碼來源:test_scheduler.py

示例5: test_requiresFromSite

 def test_requiresFromSite(self):
     """
     The value of a L{axiom.dependency.requiresFromSite} descriptor ought to
     be the powerup on the site for the instance it describes.
     """
     dependency.installOn(RealGrid(store=self.store), self.store)
     substore = SubStore.createNew(self.store, ['sub']).open()
     self.assertEquals(PowerStrip(store=substore).draw(1), REAL_POWER)
開發者ID:bne,項目名稱:squeal,代碼行數:8,代碼來源:test_dependency.py

示例6: test_requiresFromSiteNoDefault

 def test_requiresFromSiteNoDefault(self):
     """
     The default function shouldn't be needed or invoked if its value isn't
     going to be used.
     """
     dependency.installOn(RealGrid(store=self.store), self.store)
     substore = SubStore.createNew(self.store, ['sub']).open()
     self.assertEquals(SpecifiedBadDefaults(store=substore).pump(),
                       REAL_POWER)
開發者ID:bne,項目名稱:squeal,代碼行數:9,代碼來源:test_dependency.py

示例7: setUp

    def setUp(self):
        self.spath = filepath.FilePath(self.mktemp() + ".axiom")
        self.store = Store(self.spath)
        self.substoreitem = SubStore.createNew(self.store,
                                               ["sub.axiom"])

        self.substore = self.substoreitem.open()
        # Not available yet.
        self.substore.attachToParent()
開發者ID:perkinslr,項目名稱:axiom-py3,代碼行數:9,代碼來源:test_crossstore.py

示例8: setUp

 def setUp(self):
     """
     Set up the tests by creating a store and a substore and opening them both.
     """
     self.topdb = topdb = Store(filepath.FilePath(self.mktemp()))
     self.ssitem = ssitem = SubStore.createNew(
         topdb, ["dontstartme", "really"])
     self.ss = ssitem.open()
     self.serviceStarted = False
開發者ID:bne,項目名稱:squeal,代碼行數:9,代碼來源:test_substore.py

示例9: test_requiresFromSiteDefault

 def test_requiresFromSiteDefault(self):
     """
     The value of a L{axiom.dependency.requiresFromSite} descriptor on an
     item in a user store ought to be the result of invoking its default
     factory parameter.
     """
     substore = SubStore.createNew(self.store, ['sub']).open()
     ps = PowerStrip(store=substore)
     self.assertEquals(ps.draw(1), FAKE_POWER)
     self.assertEquals(ps.grid.siteStore, self.store)
開發者ID:bne,項目名稱:squeal,代碼行數:10,代碼來源:test_dependency.py

示例10: openStore

 def openStore(self):
     self.currentTopStore = store.Store(self.topdbdir)
     if self.subStoreID is not None:
         self.currentSubStore = self.currentTopStore.getItemByID(self.subStoreID).open()
     else:
         ss = SubStore.createNew(self.currentTopStore,
                                 ['sub'])
         self.subStoreID = ss.storeID
         self.currentSubStore = ss.open()
     return self.currentSubStore
開發者ID:perkinslr,項目名稱:axiom-py3,代碼行數:10,代碼來源:test_upgrading.py

示例11: createDatabase

def createDatabase(s):
    """
    Create a store which contains a substore-service-starter item powered up
    for IService, and a substore, which contains a service that should not be
    started after the upgrader runs.
    """
    ssi = SubStore.createNew(s, ["sub", "test"])
    ss = ssi.open()
    ds = DummyService(store=ss)
    ss.powerUp(ds, IService)
    ssss = SubStoreStartupService(store=s).installOn(s)
開發者ID:bne,項目名稱:squeal,代碼行數:11,代碼來源:stub_subStoreStartupService1to2.py

示例12: test_listOffering

 def test_listOffering(self):
     """
     Mantissa offerings are added as users with a 'username' but no domain.
     Check that the 'list' command prints these correctly.
     """
     name = 'offering-name'
     self.userbase('install')
     realm = IRealm(self.store)
     substoreItem = SubStore.createNew(self.store, ('app', name))
     realm.addAccount(name, None, None, internal=True,
                      avatars=substoreItem)
     output = self.userbase('list')
     self.assertEqual(output, [name])
開發者ID:perkinslr,項目名稱:axiom-py3,代碼行數:13,代碼來源:test_userbase.py

示例13: test_requiresFromSiteUnspecifiedException

 def test_requiresFromSiteUnspecifiedException(self):
     """
     If a default factory function isn't supplied, an
     L{UnsatisfiedRequirement}, which should be a subtype of
     L{AttributeError}, should be raised when the descriptor is retrieved.
     """
     lung = IronLung(store=self.store)
     siteLung = IronLung(
         store=SubStore.createNew(self.store, ['sub']).open())
     self.assertRaises(UnsatisfiedRequirement, lambda : lung.grid)
     self.assertRaises(UnsatisfiedRequirement, lambda : siteLung.grid)
     default = object()
     self.assertIdentical(getattr(lung, 'grid', default), default)
開發者ID:bne,項目名稱:squeal,代碼行數:13,代碼來源:test_dependency.py

示例14: test_memorySubstoreFile

 def test_memorySubstoreFile(self):
     """
     In-memory substores whose stores have file directories should be able
     to create files.
     """
     filesdir = filepath.FilePath(self.mktemp())
     s = Store(filesdir=filesdir)
     ss = SubStore.createNew(s, ['account', '[email protected]'])
     s2 = ss.open()
     f = s2.newFile("test.txt")
     f.write("yay")
     f.close()
     self.assertEqual(open(f.finalpath.path).read(), "yay")
開發者ID:bne,項目名稱:squeal,代碼行數:13,代碼來源:test_substore.py

示例15: insertUserStore

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()
開發者ID:perkinslr,項目名稱:axiom-py3,代碼行數:37,代碼來源:userbase.py


注:本文中的axiom.substore.SubStore類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。