mercurial/demandload.py
author Vincent Wagelaar <vincent@ricardis.tudelft.nl>
Tue, 30 Aug 2005 21:58:44 +0200
changeset 1181 4f5001f5b4c3
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
Make sure the repository names don't have slashes at the at or else in some cases env[path_info] will not find an defined repository. REQUEST_URI can contain a query_string appending the repository name would lead to corrupt urls.

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