• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pyamf.register_alias_type函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_simple

    def test_simple(self):
        class A(object):
            pass

        pyamf.register_alias_type(DummyAlias, A)

        self.assertEqual(util.get_class_alias(A), DummyAlias)
开发者ID:nervatura,项目名称:nerva2py,代码行数:7,代码来源:test_util.py


示例2: test_duplicate

    def test_duplicate(self):
        class A(object):
            pass

        pyamf.register_alias_type(DummyAlias, A)

        self.assertRaises(RuntimeError, pyamf.register_alias_type, DummyAlias, A)
开发者ID:0xmilk,项目名称:appscale,代码行数:7,代码来源:test_basic.py


示例3: test_single

    def test_single(self):
        class A(object):
            pass

        pyamf.register_alias_type(DummyAlias, A)

        self.assertTrue(DummyAlias in pyamf.ALIAS_TYPES.keys())
        self.assertEqual(pyamf.ALIAS_TYPES[DummyAlias], (A,))
开发者ID:0xmilk,项目名称:appscale,代码行数:8,代码来源:test_basic.py


示例4: test_subclass

    def test_subclass(self):
        class A(object):
            pass

        class B(A):
            pass

        pyamf.register_alias_type(DummyAlias, A)

        self.assertEquals(util.get_class_alias(B), DummyAlias)
开发者ID:AbsMate,项目名称:bluecop-xbmc-repo,代码行数:10,代码来源:test_util.py


示例5: test_multiple

    def test_multiple(self):
        class A(object):
            pass

        class B(object):
            pass

        self.assertRaises(TypeError, pyamf.register_alias_type, DummyAlias, A, 'hello')

        pyamf.register_alias_type(DummyAlias, A, B)
        self.assertTrue(DummyAlias in pyamf.ALIAS_TYPES)
        self.assertEqual(pyamf.ALIAS_TYPES[DummyAlias], (A, B))
开发者ID:0xmilk,项目名称:appscale,代码行数:12,代码来源:test_basic.py


示例6: test_nested

    def test_nested(self):
        class A(object):
            pass

        class B(object):
            pass

        class C(object):
            pass

        pyamf.register_alias_type(DummyAlias, A, B, C)

        self.assertEqual(util.get_class_alias(B), DummyAlias)
开发者ID:nervatura,项目名称:nerva2py,代码行数:13,代码来源:test_util.py


示例7: test_registered_deep

    def test_registered_deep(self):
        class A:
            pass

        class B(A):
            pass

        pyamf.register_alias_type(DummyAlias, A)
        self.addCleanup(pyamf.unregister_alias_type, DummyAlias)
        alias = self.context.getClassAlias(B)

        self.assertTrue(isinstance(alias, DummyAlias))
        self.assertIdentical(alias.klass, B)
开发者ID:nervatura,项目名称:nerva2py,代码行数:13,代码来源:test_codec.py


示例8: test_unregister

    def test_unregister(self):
        """
        Tests for L{pyamf.unregister_alias_type}
        """
        class A(object):
            pass

        self.assertFalse(DummyAlias in pyamf.ALIAS_TYPES)
        self.assertEqual(pyamf.unregister_alias_type(A), None)

        pyamf.register_alias_type(DummyAlias, A)

        self.assertTrue(DummyAlias in pyamf.ALIAS_TYPES.keys())
        self.assertEqual(pyamf.unregister_alias_type(DummyAlias), (A,))
开发者ID:0xmilk,项目名称:appscale,代码行数:14,代码来源:test_basic.py


示例9: test_registered_deep

    def test_registered_deep(self):
        x = pyamf.BaseContext()

        self.assertEquals(x.class_aliases, {})

        class A:
            pass

        class B(A):
            pass

        pyamf.register_alias_type(DummyAlias, A)
        alias = x.getClassAlias(B)

        self.assertTrue(isinstance(alias, pyamf.ClassAlias))
        self.assertEquals(alias.__class__, DummyAlias)
        self.assertEquals(alias.klass, B)
开发者ID:cardmagic,项目名称:PyAMF,代码行数:17,代码来源:test_basic.py


示例10: test_multiple

    def test_multiple(self):
        class A(object):
            pass

        class B(object):
            pass

        class C(object):
            pass

        pyamf.register_alias_type(DummyAlias, A)
        pyamf.register_alias_type(AnotherDummyAlias, B)
        pyamf.register_alias_type(YADummyAlias, C)

        self.assertEqual(util.get_class_alias(B), AnotherDummyAlias)
        self.assertEqual(util.get_class_alias(C), YADummyAlias)
        self.assertEqual(util.get_class_alias(A), DummyAlias)
开发者ID:nervatura,项目名称:nerva2py,代码行数:17,代码来源:test_util.py


示例11: applyAttributes

        return attrs

    def applyAttributes(self, obj, attrs, **kwargs):
        """
        Applies C{attrs} to C{obj}. Since C{blobstore.BlobInfo} objects are
        read-only entities, we only care about the C{key} attribute.
        """
        assert type(obj) is BlobInfoStub

        key = attrs.pop('key', None)

        if not key:
            raise pyamf.DecodeError("Unable to build blobstore.BlobInfo "
                "instance. Missing 'key' attribute.")

        try:
            key = blobstore.BlobKey(key)
        except:
            raise pyamf.DecodeError("Unable to build a valid blobstore.BlobKey "
                "instance. Key supplied was %r" % (key,))

        obj.__class__ = blobstore.BlobInfo

        obj.__init__(key)


pyamf.register_alias_type(BlobInfoClassAlias, bi)
pyamf.register_class(bi, '.'.join([blobstore.__name__, bi.__name__]))

del bi
开发者ID:Armedite,项目名称:xbmc-catchuptv-au,代码行数:30,代码来源:_google_appengine_ext_blobstore.py


示例12: getGAEObjects

    C{object.__class__: {key1: object1, key2: object2, .., keyn: objectn}}. We
    use the datastore key to do the reference checking.

    @since: 0.4.1
    """
    if not obj.is_saved():
        encoder.writeObject(obj)

        return

    context = encoder.context
    kls = obj.__class__
    s = obj.key()

    gae_objects = getGAEObjects(context)

    try:
        referenced_object = gae_objects.getClassKey(kls, s)
    except KeyError:
        referenced_object = obj
        gae_objects.addClassKey(kls, s, obj)

    encoder.writeObject(referenced_object)


# initialise the module here: hook into pyamf

pyamf.register_alias_type(DataStoreClassAlias, db.Model)
pyamf.add_type(db.Query, util.to_list)
pyamf.add_type(db.Model, writeGAEObject)
开发者ID:meemeer,项目名称:kayframework-pyamf,代码行数:30,代码来源:_google_appengine_ext_db.py


示例13: test_subclass

 def test_subclass(self):
     self.assertFalse(issubclass(self.__class__, pyamf.ClassAlias))
     with self.assertRaises(ValueError):
         pyamf.register_alias_type(self.__class__)
开发者ID:nervatura,项目名称:nerva2py,代码行数:4,代码来源:test_basic.py


示例14: type

        read-only entities, we only care about the C{key} attribute.
        """
        assert type(obj) is BlobInfoStub

        key = attrs.pop('key', None)

        if not key:
            raise pyamf.DecodeError(
                "Unable to build blobstore.BlobInfo instance. Missing 'key' "
                "attribute."
            )

        try:
            key = blobstore.BlobKey(key)
        except:
            raise pyamf.DecodeError(
                "Unable to build a valid blobstore.BlobKey instance. Key "
                "supplied was %r" % (key,)
            )

        obj.__class__ = blobstore.BlobInfo

        obj.__init__(key)


pyamf.register_alias_type(BlobInfoClassAlias, blobstore.BlobInfo)
pyamf.register_class(blobstore.BlobInfo, '.'.join([
    blobstore.__name__,
    blobstore.BlobInfo.__name__
]))
开发者ID:Khan,项目名称:frankenserver,代码行数:30,代码来源:_google_appengine_ext_blobstore.py


示例15: map_mongoengine_document

        fields = obj._fields
        for key, value in attrs.items():
            if key not in fields.keys():
                print "Got unknown key '%s' for %r" % (key, obj)
                del attrs[key]
        return attrs


def map_mongoengine_document(klass):
    if not isinstance(klass, type):
        klass = type(klass)
    if issubclass(klass, BaseDocument):
        return True
    return False


def objectIDHack(obj, encoder=None):
    """
    For some reason ObjectIDs fuck everything up. I dont know why and when I try to find
    out I end up smashing things. So here a little hack!

    @param obj:
    @param encoder:
    @return:
    """
    encoder.writeObject({})


pyamf.register_alias_type(MongoEngineDocumentAlias, map_mongoengine_document)
pyamf.add_type(ObjectId, objectIDHack)
开发者ID:RockingRolli,项目名称:pyamf,代码行数:30,代码来源:_mongoengine.py


示例16: str

        if self.descriptor.parent:
            self.parent_descriptor = self.descriptor.parent._descriptor

        foreign_constraints = []

        for constraint in self.descriptor.constraints:
            for col in constraint.columns:
                col = str(col)

                if adapter.__version__.startswith('0.6'):
                    foreign_constraints.append(col)
                else:
                    if col.startswith(self.descriptor.tablename + '.'):
                        foreign_constraints.append(
                            col[len(self.descriptor.tablename) + 1:]
                        )

        if self.descriptor.polymorphic:
            self.exclude_attrs.update([self.descriptor.polymorphic])

        self.exclude_attrs.update(foreign_constraints)

    def _compile_base_class(self, klass):
        if klass is elixir.EntityBase or klass is elixir.Entity:
            return

        pyamf.ClassAlias._compile_base_class(self, klass)


pyamf.register_alias_type(ElixirAdapter, elixir.entity.is_entity)
开发者ID:nervatura,项目名称:nerva2py,代码行数:30,代码来源:_elixir.py


示例17: post_ndb_process

        datetime.time(0, 0, 0)
    )


def post_ndb_process(payload, context):
    """
    """
    stubs = context.get(NDB_STUB_NAME, None)

    if not stubs:
        return payload

    stubs.transform()

    return payload


# small optimisation to compile the ndb.Model base class
if hasattr(ndb.model, '_NotEqualMixin'):
    not_equal_mixin = pyamf.register_class(ndb.model._NotEqualMixin)
    not_equal_mixin.compile()

    del not_equal_mixin

# initialise the module here: hook into pyamf
pyamf.register_alias_type(NDBClassAlias, ndb.Model, ndb.Expando)
pyamf.add_type(ndb.Query, util.to_list)
pyamf.add_type(ndb.Model, encode_ndb_instance)
pyamf.add_post_decode_processor(post_ndb_process)
pyamf.add_type(ndb.Key, encode_ndb_key)
开发者ID:Khan,项目名称:frankenserver,代码行数:30,代码来源:_google_appengine_ext_ndb.py


示例18: install_gae_reference_model_hook

    try:
        referenced_object = gae_objects.getClassKey(kls, s)
    except KeyError:
        gae_objects.addClassKey(kls, s, object)
        self.writeNonGAEObject(object, *args, **kwargs)

        return

    self.writeNonGAEObject(referenced_object, *args, **kwargs)

def install_gae_reference_model_hook(mod):
    """
    Called when L{pyamf.amf0} or L{pyamf.amf3} are imported. Attaches the
    L{writeGAEObject} method to the C{Encoder} class in that module.

    @param mod: The module imported.
    @since: 0.4.1
    """
    if not hasattr(mod.Encoder, 'writeNonGAEObject'):
        mod.Encoder.writeNonGAEObject = mod.Encoder.writeObject
        mod.Encoder.writeObject = writeGAEObject

# initialise the module here: hook into pyamf

pyamf.add_type(db.Query, util.to_list)
pyamf.register_alias_type(DataStoreClassAlias, db.Model, db.Expando)

# hook the L{writeGAEObject} method to the Encoder class on import
imports.whenImported('pyamf.amf0', install_gae_reference_model_hook)
imports.whenImported('pyamf.amf3', install_gae_reference_model_hook)
开发者ID:feisley,项目名称:petetweet,代码行数:30,代码来源:_google_appengine_ext_db.py


示例19: createInstance

        if self.KEY_ATTR in attrs:
            del attrs[self.KEY_ATTR]

        return attrs

    def createInstance(self, *args, **kwargs):
        self.compile()

        return self.mapper.class_manager.new_instance()


def is_class_sa_mapped(klass):
    """
    @rtype: C{bool}
    """
    if not isinstance(klass, type):
        klass = type(klass)

    for c in class_checkers:
        if c(klass):
            return False

    try:
        class_mapper(klass)
    except UnmappedInstanceError:
        return False

    return True

pyamf.register_alias_type(SaMappedClassAlias, is_class_sa_mapped)
开发者ID:cardmagic,项目名称:PyAMF,代码行数:30,代码来源:_sqlalchemy_orm.py


示例20: Hash

        details_hash = Hash(details_hash)
        self.uid = details_hash.getlist('uid')
        self.givenName = details_hash.get('givenName')
        self.sn = details_hash.get('sn') # surname
        self.cn = details_hash.get('cn') # givenName + surname
        self.ispmanUserId = details_hash.get('ispmanUserId')
        self.mailLocalAddress = details_hash.get('mailLocalAddress')
        self.userPassword = details_hash.get('userPassword')
        self.mailForwardingAddress = details_hash.getlist('mailForwardingAddress')
        self.FTPStatus = details_hash.get('FTPStatus')
        self.FTPQuotaMBytes = details_hash.getint('FTPQuotaMBytes')
        self.mailQuota = details_hash.getint('mailQuota')
        self.ispmanCreateTimestamp = details_hash.getint('ispmanCreateTimestamp')
        self.mailAlias = details_hash.getlist('mailAlias')
        log.debug(self.uid)

    def __repr__(self):
        return "<%s - UID: %s; CN: '%s';>" % (self.__class__.__name__,
                                              self.uid, self.cn)

class DomainUserClassAlias(pyamf.ClassAlias):

    def createInstance(self, codec=None, *args, **kwargs):
        log.debug("CODEC: %r; ARGS: %r; KWARGS: %r", codec, args, kwargs)
        return DomainUser(args[0], kwargs)

    def checkClass(self, klass):
        pass

pyamf.register_alias_type(DomainUserClassAlias, DomainUser)
开发者ID:UfSoft,项目名称:ISPMan-Twisted-Flex,代码行数:30,代码来源:user.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyamf.register_class函数代码示例发布时间:2022-05-25
下一篇:
Python pyamf.get_encoder函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap