def moduleFactoryFactory(factory):
    moduleCache = {}

    def moduleFactory(baseModule, *args, **kwargs):
        if (type(ModuleType.__name__) is unicode):
            name = (u'_%s_factory' % baseModule.__name__)
        else:
            name = ('_%s_factory' % baseModule.__name__)
        if (name in moduleCache):
            return moduleCache[name]
        else:
            mod = ModuleType(name)
            objs = factory(baseModule, *args, **kwargs)
            mod.__dict__.update(objs)
            moduleCache[name] = mod
            return mod
    moduleFactory.func_annotations = {}
    return moduleFactory
def moduleFactoryFactory(factory):
    moduleCache = {}

    def moduleFactory(baseModule, *args, **kwargs):
        if (type(ModuleType.__name__) is unicode):
            name = (u'_%s_factory' % baseModule.__name__)
        else:
            name = ('_%s_factory' % baseModule.__name__)
        if (name in moduleCache):
            return moduleCache[name]
        else:
            mod = ModuleType(name)
            objs = factory(baseModule, *args, **kwargs)
            mod.__dict__.update(objs)
            moduleCache[name] = mod
            return mod
    moduleFactory.func_annotations = {}
    return moduleFactory