当前位置: 首页>>代码示例>>Python>>正文


Python sob.load函数代码示例

本文整理汇总了Python中twisted.persisted.sob.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testNames

 def testNames(self):
     o = [1, 2, 3]
     p = sob.Persistent(o, "object")
     for style in "source pickle".split():
         p.setStyle(style)
         p.save()
         o1 = sob.load("object.ta" + style[0], style)
         self.assertEqual(o, o1)
         for tag in "lala lolo".split():
             p.save(tag)
             o1 = sob.load("object-" + tag + ".ta" + style[0], style)
             self.assertEqual(o, o1)
开发者ID:ssilverek,项目名称:kodb,代码行数:12,代码来源:test_sob.py

示例2: testNames

 def testNames(self):
     o = [1,2,3]
     p = sob.Persistent(o, 'object')
     for style in 'source pickle'.split():
         p.setStyle(style)
         p.save()
         o1 = sob.load('object.ta'+style[0], style)
         self.failUnlessEqual(o, o1)
         for tag in 'lala lolo'.split():
             p.save(tag)
             o1 = sob.load('object-'+tag+'.ta'+style[0], style)
             self.failUnlessEqual(o, o1)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:12,代码来源:test_sob.py

示例3: test_saveEncryptedDeprecation

    def test_saveEncryptedDeprecation(self):
        """
        Persisting data with encryption is deprecated.
        """
        tempDir = FilePath(self.mktemp())
        tempDir.makedirs()
        persistedPath = tempDir.child('epersisttest.python')
        data = b'once I was the king of spain'
        persistance = sob.Persistent(data, 'test-data')

        persistance.save(filename=persistedPath.path, passphrase=b'some-pass')

        # Check deprecation message.
        warnings = self.flushWarnings([persistance._saveTemp])
        self.assertEqual(1, len(warnings))
        self.assertIs(DeprecationWarning, warnings[0]['category'])
        self.assertEqual(
            'Saving encrypted persisted data is deprecated since '
            'Twisted 15.5.0',
            warnings[0]['message'])
        # Check that data is still valid, even if we are deprecating this
        # functionality.
        loadedData = sob.load(
            persistedPath.path, persistance.style, b'some-pass')
        self.assertEqual(data, loadedData)
        self.flushWarnings([sob.load])
开发者ID:Architektor,项目名称:PySnip,代码行数:26,代码来源:test_sob.py

示例4: testStyles

 def testStyles(self):
     for o in objects:
         p = sob.Persistent(o, '')
         for style in 'source pickle'.split():
             p.setStyle(style)
             p.save(filename='persisttest.'+style)
             o1 = sob.load('persisttest.'+style, style)
             self.failUnlessEqual(o, o1)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:8,代码来源:test_sob.py

示例5: restore

 def restore(self):
     if not self.filename:
         raise exceptions.StateRestoreError, \
             "It appears that state was never saved; cannot restore"
     if os.path.exists(self.filename):
         s = sob.load(self.filename, 'pickle')
         for key, val in s.__dict__.items():
             setattr(self, key, val)
开发者ID:Darkpaw95,项目名称:pymon,代码行数:8,代码来源:application.py

示例6: testStyles

 def testStyles(self):
     for o in objects:
         p = sob.Persistent(o, "")
         for style in "source pickle".split():
             p.setStyle(style)
             p.save(filename="persisttest." + style)
             o1 = sob.load("persisttest." + style, style)
             self.assertEqual(o, o1)
开发者ID:ssilverek,项目名称:kodb,代码行数:8,代码来源:test_sob.py

示例7: testEverythingEphemeralGetattr

    def testEverythingEphemeralGetattr(self):
        """
        Verify that _EverythingEphermal.__getattr__ works.
        """
        self.fakeMain.testMainModGetattr = 1

        dirname = self.mktemp()
        os.mkdir(dirname)

        filename = os.path.join(dirname, 'persisttest.ee_getattr')

        f = file(filename, 'w')
        f.write('import __main__\n')
        f.write('if __main__.testMainModGetattr != 1: raise AssertionError\n')
        f.write('app = None\n')
        f.close()

        sob.load(filename, 'source')
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:18,代码来源:test_sob.py

示例8: testEncryptedStyles

 def testEncryptedStyles(self):
     for o in objects:
         phrase='once I was the king of spain'
         p = sob.Persistent(o, '')
         for style in 'source pickle'.split():
             p.setStyle(style)
             p.save(filename='epersisttest.'+style, passphrase=phrase)
             o1 = sob.load('epersisttest.'+style, style, phrase)
             self.failUnlessEqual(o, o1)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:9,代码来源:test_sob.py

示例9: testEncryptedStyles

 def testEncryptedStyles(self):
     for o in objects:
         phrase = b"once I was the king of spain"
         p = sob.Persistent(o, "")
         for style in "source pickle".split():
             p.setStyle(style)
             p.save(filename="epersisttest." + style, passphrase=phrase)
             o1 = sob.load("epersisttest." + style, style, phrase)
             self.assertEqual(o, o1)
开发者ID:ssilverek,项目名称:kodb,代码行数:9,代码来源:test_sob.py

示例10: testEverythingEphemeralSetattr

    def testEverythingEphemeralSetattr(self):
        """
        Verify that _EverythingEphemeral.__setattr__ won't affect __main__.
        """
        self.fakeMain.testMainModSetattr = 1

        dirname = self.mktemp()
        os.mkdir(dirname)

        filename = os.path.join(dirname, 'persisttest.ee_setattr')
        with open(filename, 'w') as f:
            f.write('import __main__\n')
            f.write('__main__.testMainModSetattr = 2\n')
            f.write('app = None\n')

        sob.load(filename, 'source')

        self.assertEqual(self.fakeMain.testMainModSetattr, 1)
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:18,代码来源:test_sob.py

示例11: testStylesBeingSet

 def testStylesBeingSet(self):
     o = Dummy()
     o.foo = 5
     o.setComponent(sob.IPersistable, sob.Persistent(o, 'lala'))
     for style in 'source pickle'.split():
         sob.IPersistable(o).setStyle(style)
         sob.IPersistable(o).save(filename='lala.'+style)
         o1 = sob.load('lala.'+style, style)
         self.failUnlessEqual(o.foo, o1.foo)
         self.failUnlessEqual(sob.IPersistable(o1).style, style)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:10,代码来源:test_sob.py

示例12: testStyles

 def testStyles(self):
     for o in objects:
         p = sob.Persistent(o, '')
         for style in 'xml source pickle'.split():
             if style == 'xml' and not gotMicrodom:
                 continue
             p.setStyle(style)
             p.save(filename='persisttest.'+style)
             o1 = sob.load('persisttest.'+style, style)
             self.failUnlessEqual(o, o1)
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:10,代码来源:test_sob.py

示例13: testStylesBeingSet

 def testStylesBeingSet(self):
     o = Dummy()
     o.foo = 5
     o.setComponent(sob.IPersistable, sob.Persistent(o, "lala"))
     for style in "source pickle".split():
         sob.IPersistable(o).setStyle(style)
         sob.IPersistable(o).save(filename="lala." + style)
         o1 = sob.load("lala." + style, style)
         self.assertEqual(o.foo, o1.foo)
         self.assertEqual(sob.IPersistable(o1).style, style)
开发者ID:ssilverek,项目名称:kodb,代码行数:10,代码来源:test_sob.py

示例14: test_encryptedStyles

 def test_encryptedStyles(self):
     """
     Data can be persisted with encryption for all the supported styles.
     """
     for o in objects:
         phrase = b'once I was the king of spain'
         p = sob.Persistent(o, '')
         for style in 'source pickle'.split():
             p.setStyle(style)
             p.save(filename='epersisttest.'+style, passphrase=phrase)
             o1 = sob.load('epersisttest.'+style, style, phrase)
             self.assertEqual(o, o1)
             self.flushWarnings([p._saveTemp, sob.load])
开发者ID:Architektor,项目名称:PySnip,代码行数:13,代码来源:test_sob.py

示例15: testEncryptedStyles

 def testEncryptedStyles(self):
     try:
         import Crypto
     except ImportError:
         raise unittest.SkipTest()
     for o in objects:
         phrase='once I was the king of spain'
         p = sob.Persistent(o, '')
         for style in 'xml source pickle'.split():
             if style == 'xml' and not gotMicrodom:
                 continue
             p.setStyle(style)
             p.save(filename='epersisttest.'+style, passphrase=phrase)
             o1 = sob.load('epersisttest.'+style, style, phrase)
             self.failUnlessEqual(o, o1)
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:15,代码来源:test_sob.py


注:本文中的twisted.persisted.sob.load函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。