本文整理汇总了Python中pyamf.register_class_loader函数的典型用法代码示例。如果您正苦于以下问题:Python register_class_loader函数的具体用法?Python register_class_loader怎么用?Python register_class_loader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了register_class_loader函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_load_unknown_class
def test_load_unknown_class(self):
def class_loader(x):
return None
pyamf.register_class_loader(class_loader)
self.assertRaises(pyamf.UnknownClassAlias, pyamf.load_class, 'spam.eggs')
开发者ID:0xmilk,项目名称:appscale,代码行数:7,代码来源:test_basic.py
示例2: test_load_class_bad_return
def test_load_class_bad_return(self):
def class_loader(x):
return 'xyz'
pyamf.register_class_loader(class_loader)
self.assertRaises(TypeError, pyamf.load_class, 'spam.eggs')
开发者ID:0xmilk,项目名称:appscale,代码行数:7,代码来源:test_basic.py
示例3: test_unregister
def test_unregister(self):
self.assertTrue(chr not in pyamf.CLASS_LOADERS)
pyamf.register_class_loader(chr)
self.assertTrue(chr in pyamf.CLASS_LOADERS)
pyamf.unregister_class_loader(chr)
self.assertTrue(chr not in pyamf.CLASS_LOADERS)
self.assertRaises(LookupError, pyamf.unregister_class_loader, chr)
开发者ID:0xmilk,项目名称:appscale,代码行数:9,代码来源:test_basic.py
示例4: test_load_class_by_alias
def test_load_class_by_alias(self):
def class_loader(x):
self.assertEqual(x, 'spam.eggs')
return pyamf.ClassAlias(Spam, 'spam.eggs')
pyamf.register_class_loader(class_loader)
self.assertTrue('spam.eggs' not in pyamf.CLASS_CACHE.keys())
pyamf.load_class('spam.eggs')
self.assertTrue('spam.eggs' in pyamf.CLASS_CACHE.keys())
开发者ID:0xmilk,项目名称:appscale,代码行数:10,代码来源:test_basic.py
示例5: test_load_class_by_alias
def test_load_class_by_alias(self):
def class_loader(x):
self.assertEquals(x, "spam.eggs")
return pyamf.ClassAlias(Spam, "spam.eggs")
pyamf.register_class_loader(class_loader)
self.assertTrue("spam.eggs" not in pyamf.CLASS_CACHE.keys())
pyamf.load_class("spam.eggs")
self.assertTrue("spam.eggs" in pyamf.CLASS_CACHE.keys())
开发者ID:cardmagic,项目名称:PyAMF,代码行数:10,代码来源:test_basic.py
示例6: test_bad_register
def test_bad_register(self):
self.assertRaises(TypeError, pyamf.register_class_loader, 1)
pyamf.register_class_loader(ord)
开发者ID:0xmilk,项目名称:appscale,代码行数:3,代码来源:test_basic.py
示例7: test_register
def test_register(self):
self.assertTrue(chr not in pyamf.CLASS_LOADERS)
pyamf.register_class_loader(chr)
self.assertTrue(chr in pyamf.CLASS_LOADERS)
开发者ID:0xmilk,项目名称:appscale,代码行数:4,代码来源:test_basic.py
示例8: __init__
def __init__(self, alias):
dict.__init__(self)
def __readamf__(self, input):
data = input.readObject()
self["data"] = data
def pyamf_class_loader(s):
for i in pyamf.CLASS_LOADERS:
if i != pyamf_class_loader:
v = i(s)
if v:
return v
return DummyObject
pyamf.register_class_loader(pyamf_class_loader)
class ViewAMF:
name = "AMF"
prompt = ("amf", "f")
content_types = ["application/x-amf"]
def unpack(self, b, seen=set([])):
if hasattr(b, "body"):
return self.unpack(b.body, seen)
if isinstance(b, DummyObject):
if id(b) in seen:
return "<recursion>"
else:
seen.add(id(b))
for k, v in b.items():
开发者ID:camerony,项目名称:mitmproxy,代码行数:31,代码来源:contentview.py
示例9: register_alias
"""
def register_alias(cls, alias, static_attrs=None, exclude_attrs=None, dynamic=True):
if static_attrs is None and hasattr(cls, '__slots__'):
static_attrs = cls.__slots__
class_alias = ClassAlias(cls, alias, static_attrs=static_attrs, exclude_attrs=exclude_attrs, dynamic=dynamic)
_amf_aliases[alias] = class_alias
CLASS_CACHE[cls] = class_alias
def _class_loader(alias):
return _amf_aliases.get(alias)
register_class_loader(_class_loader)
def _keys_to_string(s):
if isinstance(s, dict):
re = {}
for k, v in s.iteritems():
k = unicode(k)
if not k:
continue
re[k] = _keys_to_string(v)
return re
elif isinstance(s, (list, tuple, set)):
re = []
for v in s:
re.append(_keys_to_string(v))
开发者ID:sunrize531,项目名称:cherry-common,代码行数:31,代码来源:_amf.py
注:本文中的pyamf.register_class_loader函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论