1. class_register = {}
  2.  
  3. class Foo(object):
  4. def __init__(self, **kwargs):
  5. class_register[self.__class__.__name__] = ?? # what to store here?
  6. self.__dict__.update(kwargs)
  7.  
  8. new_instance = class_register[result['class_name']](**result['data'])
  9.  
  10. class_register[self.__class__.__name__] = self.__class__
  11.  
  12. def register(cls):
  13. class_register[cls.__name__] = cls
  14.  
  15. class Foo(object):
  16. # blah blah
  17.  
  18. register(Foo)
  19.  
  20. def register(cls):
  21. class_register[cls.__name__] = cls
  22. return cls
  23.  
  24. @register
  25. class Foo(object):
  26. # blah blah