Example #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
Example #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)
Example #3
0
 def __init__(class_, *args, **kw):
     type.__init__(class_, *args, **kw)
     _troveClassesByType[class_.troveType] = class_
     apiutils.register_freezable_classmap('BuildTrove', class_)
Example #4
0
 def __init__(class_, *args, **kw):
     type.__init__(class_, *args, **kw)
     _troveClassesByType[class_.troveType] = class_
     apiutils.register_freezable_classmap("BuildTrove", class_)
Example #5
0
 def __init__(class_, *args, **kw):
     type.__init__(class_, *args, **kw)
     apiutils.register_freezable_classmap('TroveSettings', class_)