本文整理汇总了Python中pyamf.unregister_class函数的典型用法代码示例。如果您正苦于以下问题:Python unregister_class函数的具体用法?Python unregister_class怎么用?Python unregister_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unregister_class函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dynamic
def test_dynamic(self):
class Foo(pyamf.ASObject):
pass
def attr_func(obj):
self.assertTrue(isinstance(obj, Foo))
return ['hello']
x = Foo()
x.foo = 'bar'
x.hello = 'world'
y = Foo()
y.hello = x.hello
pyamf.register_class(Foo, 'x', attr_func=attr_func,
metadata=['dynamic'])
self._run([(x, '\x10\x00\x01x\x00\x03foo\x02\x00\x03bar\x00\x05hello'
'\x02\x00\x05world\x00\x00\t')])
pyamf.unregister_class(Foo)
pyamf.register_class(Foo, 'x', attrs=['hello'], attr_func=attr_func,
metadata=['dynamic'])
self._run([(x, '\x10\x00\x01x\x00\x03foo\x02\x00\x03bar\x00\x05hello'
'\x02\x00\x05world\x00\x00\t')])
pyamf.unregister_class(Foo)
pyamf.register_class(Foo, 'x', attrs=['foo'], attr_func=attr_func,
metadata=['dynamic'])
self._run([(x, '\x10\x00\x01x\x00\x03foo\x02\x00\x03bar\x00\x05hello'
'\x02\x00\x05world\x00\x00\t')])
示例2: tearDown
def tearDown(self):
import pyamf
pyamf.unregister_class(status.Status)
if self._old_alias:
pyamf.register_class(self._old_alias)
示例3: tearDown
def tearDown(self):
self.class_mapper.unmapClass(self.TestObject)
self.class_mapper.unmapClass(self.TestSubObject)
if use_pyamf is True:
pyamf.unregister_class(self.TestObject)
pyamf.unregister_class(self.TestSubObject)
示例4: test_klass
def test_klass(self):
alias = pyamf.register_class(Spam, 'spam.eggs')
pyamf.unregister_class(Spam)
self.assertTrue('spam.eggs' not in pyamf.CLASS_CACHE.keys())
self.assertTrue(Spam not in pyamf.CLASS_CACHE.keys())
self.assertTrue(alias not in pyamf.CLASS_CACHE)
示例5: test_simple
def test_simple(self):
class A(object):
pass
pyamf.register_class(A, 'A', attrs=['a'])
class B(A):
pass
pyamf.register_class(B, 'B', attrs=['b'])
x = B()
x.a = 'spam'
x.b = 'eggs'
stream = util.BufferedByteStream()
encoder = pyamf._get_encoder_class(pyamf.AMF0)(stream)
encoder.writeElement(x)
self.assertEquals(stream.getvalue(), '\x10\x00\x01B\x00\x01b\x02\x00'
'\x04eggs\x00\x01a\x02\x00\x04spam\x00\x00\t')
pyamf.unregister_class(A)
pyamf.unregister_class(B)
示例6: test_setstate_classic
def test_setstate_classic(self):
self.executed = False
class Foo:
tc = self
def __init__(self, *args, **kwargs):
self.tc.fail("__init__ called")
def __setstate__(self, state):
self.tc.executed = True
self.__dict__.update(state)
pyamf.register_class(Foo, 'foo')
self.buf.write('\x10\x00\x03\x66\x6f\x6f\x00\x04\x65\x67\x67\x73\x01\x01\x00\x04')
self.buf.write('\x73\x70\x61\x6d\x02\x00\x05\x68\x65\x6c\x6c\x6f\x00\x00\x09')
self.buf.seek(0)
foo = self.decoder.readElement()
self.assertTrue(self.executed)
self.assertTrue(isinstance(foo, Foo))
self.assertEquals(foo.spam, 'hello')
self.assertEquals(foo.eggs, True)
pyamf.unregister_class(Foo)
示例7: test_dynamic
def test_dynamic(self):
pyamf.register_class(Spam, 'abc.xyz', metadata='dynamic')
x = Spam({'spam': 'eggs'})
self.encoder.writeElement(x)
self.assertEquals(self.stream.getvalue(), '\n\x0b\x0fabc.xyz\tspam\x06\teggs\x01')
pyamf.unregister_class(Spam)
示例8: test_class_references
def test_class_references(self):
pyamf.register_class(Spam, 'abc.xyz')
x = Spam({'spam': 'eggs'})
y = Spam({'spam': 'baz'})
self.encoder.writeElement(x)
pyamf.unregister_class(Spam)
示例9: test_force_amf3
def test_force_amf3(self):
pyamf.register_class(Spam, 'spam.eggs', metadata=['amf3'])
x = Spam()
x.x = 'y'
self._run([
(x, '\x11\n\x0b\x13spam.eggs\x03x\x06\x03y\x01')])
pyamf.unregister_class(Spam)
示例10: test_typed_object
def test_typed_object(self):
pyamf.register_class(Spam, alias='org.pyamf.spam')
x = Spam()
x.baz = 'hello'
self.encoder.writeElement(x)
self.assertEquals(self.buf.getvalue(),
'\x10\x00\x0eorg.pyamf.spam\x00\x03baz\x02\x00\x05hello\x00\x00\t')
pyamf.unregister_class(Spam)
示例11: tearDown
def tearDown(self):
try:
self.jessica.delete()
except:
pass
if self.jessica_expando.is_saved():
self.jessica_expando.delete()
try:
pyamf.unregister_class(PetModel)
except:
pass
示例12: test_dynamic
def test_dynamic(self):
class Foo(pyamf.ASObject):
pass
x = Foo()
x.foo = 'bar'
alias = pyamf.register_class(Foo, 'x')
alias.exclude_attrs = ['hello']
self._run([(x, '\x10\x00\x01x\x00\x03foo\x02\x00\x03bar\x00\x05hello'
'\x02\x00\x05world\x00\x00\t')])
pyamf.unregister_class(Foo)
示例13: test_combined
def test_combined(self):
def wf(obj):
return ['eggs']
pyamf.register_class(Spam, 'abc.xyz', attrs=['spam'], attr_func=wf)
x = Spam({'spam': 'foo', 'eggs': 'bar'})
self.encoder.writeElement(x)
buf = self.stream.getvalue()
self.assertEquals(buf, '\n\x1b\x0fabc.xyz\tspam\x06\x07foo\teggs\x06\x07bar\x01')
pyamf.unregister_class(Spam)
示例14: test_get_alias
def test_get_alias(self):
pyamf.register_class(Spam, 'spam.eggs')
x = amf3.ClassDefinition('spam.eggs')
alias = x.getClassAlias()
self.assertEquals(alias.klass, Spam)
self.assertEquals(alias.alias, 'spam.eggs')
pyamf.unregister_class(Spam)
x = amf3.ClassDefinition(None)
self.assertRaises(pyamf.UnknownClassAlias, x.getClassAlias)
x = amf3.ClassDefinition('')
self.assertRaises(pyamf.UnknownClassAlias, x.getClassAlias)
示例15: test_object
def test_object(self):
self._run([
({'a': u'spam', 'b': 5},
'\n\x0b\x01\x03a\x06\tspam\x03b\x04\x05\x01')])
pyamf.register_class(Spam, 'org.pyamf.spam')
obj = Spam()
obj.baz = 'hello'
self.encoder.writeElement(obj)
self.assertEqual(self.buf.getvalue(), '\n\x0b\x1dorg.pyamf.spam\x07baz'
'\x06\x0bhello\x01')
pyamf.unregister_class(Spam)