Commit 58f0b087 authored by Nicolas Dumazet's avatar Nicolas Dumazet

indentation: 4 to 2 spaces


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39762 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2bc803d5
......@@ -2,26 +2,26 @@ from types import ModuleType
import sys
class DynamicModule(ModuleType):
"""This module may generate new objects at runtime."""
# it's useful to have such a generic utility
# please subclass it if you need ERP5-specific behaviors
"""This module may generate new objects at runtime."""
# it's useful to have such a generic utility
# please subclass it if you need ERP5-specific behaviors
def __init__(self, name, factory, doc=None):
super(DynamicModule, self).__init__(name, doc=doc)
self._factory = factory
def __init__(self, name, factory, doc=None):
super(DynamicModule, self).__init__(name, doc=doc)
self._factory = factory
def __getattr__(self, name):
if name == '__path__':
raise AttributeError('%s does not have __path__' % (self,))
obj = self._factory(name)
# _factory can return an instance, a constant, or a class
if isinstance(obj, type):
# if it's a class we want to set __module__
obj.__module__ = self.__name__
setattr(self, name, obj)
return obj
def __getattr__(self, name):
if name == '__path__':
raise AttributeError('%s does not have __path__' % (self,))
obj = self._factory(name)
# _factory can return an instance, a constant, or a class
if isinstance(obj, type):
# if it's a class we want to set __module__
obj.__module__ = self.__name__
setattr(self, name, obj)
return obj
def registerDynamicModule(name, factory):
d = DynamicModule(name, factory)
sys.modules[name] = d
return d
d = DynamicModule(name, factory)
sys.modules[name] = d
return d
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment