Commit 73d54c69 authored by Julien Muchembled's avatar Julien Muchembled

dynamic_module: set __file__ so that ipython does not fail to display traceback

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42274 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 589f0e5f
......@@ -6,13 +6,16 @@ class DynamicModule(ModuleType):
# it's useful to have such a generic utility
# please subclass it if you need ERP5-specific behaviors
__file__ = __file__
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,))
if name[:2] == '__':
raise AttributeError('%r module has no attribute %r'
% (self.__name__, name))
obj = self._factory(name)
# _factory can return an instance, a constant, or a class
if isinstance(obj, type):
......
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