mercurial/demandload.py
author Thomas Arendsen Hein <thomas@intevation.de>
Mon, 29 Aug 2005 07:42:46 +0200
changeset 1144 8a39df05d2c1
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
Documented passing list or dict instead of config file in hgwebdir.cgi

def demandload(scope, modules):
    class d:
        def __getattr__(self, name):
            mod = self.__dict__["mod"]
            scope = self.__dict__["scope"]
            scope[mod] = __import__(mod, scope, scope, [])
            return getattr(scope[mod], name)

    for m in modules.split():
        dl = d()
        dl.mod = m
        dl.scope = scope
        scope[m] = dl