示例#1
0
    def testRegisterFreezableClassmap(self):
        class Freezable(object):
            def __freeze__(self):
                return {}

            @classmethod
            def __thaw__(class_, d):
                return class_()

        class Foo(Freezable):
            pass

        class Bar(Freezable):
            pass

        apiutils.register_freezable_classmap("mytype", Foo)
        apiutils.register_freezable_classmap("mytype", Bar)

        assert apiutils.thaw("mytype", apiutils.freeze("mytype", Foo())).__class__ == Foo
        assert apiutils.thaw("mytype", apiutils.freeze("mytype", Bar())).__class__ == Bar
示例#2
0
    def testRegisterFreezableClassmap(self):
        class Freezable(object):
            def __freeze__(self):
                return {}

            @classmethod
            def __thaw__(class_, d):
                return class_()

        class Foo(Freezable):
            pass

        class Bar(Freezable):
            pass

        apiutils.register_freezable_classmap('mytype', Foo)
        apiutils.register_freezable_classmap('mytype', Bar)

        assert (apiutils.thaw('mytype',
                              apiutils.freeze('mytype',
                                              Foo())).__class__ == Foo)
        assert (apiutils.thaw('mytype',
                              apiutils.freeze('mytype',
                                              Bar())).__class__ == Bar)
示例#3
0
 def __init__(class_, *args, **kw):
     type.__init__(class_, *args, **kw)
     _troveClassesByType[class_.troveType] = class_
     apiutils.register_freezable_classmap('BuildTrove', class_)
示例#4
0
 def __init__(class_, *args, **kw):
     type.__init__(class_, *args, **kw)
     _troveClassesByType[class_.troveType] = class_
     apiutils.register_freezable_classmap("BuildTrove", class_)
示例#5
0
 def __init__(class_, *args, **kw):
     type.__init__(class_, *args, **kw)
     apiutils.register_freezable_classmap('TroveSettings', class_)