view mercurial/demandload.py @ 369:09f24af48b82

hgweb: fix deleted file in changeset key error -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hgweb: fix deleted file in changeset key error We simply point to nullid. This is very arguably the correct thing to do. manifest hash: c16f1c05a087e5d3274cb84dfd09d048430f0495 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsPCdywK+sNU5EO8RAuJzAJ9j2Yn7KHceFxYgKvOd5V4fNNLKmQCfTZ9s jorkRZcX2hdZqRkxM8q8VMk= =+bEb -----END PGP SIGNATURE-----
author mpm@selenic.com
date Wed, 15 Jun 2005 19:23:09 -0800
parents 3db700146536
children f3abe0bdccdd
line wrap: on
line source

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