view mercurial/demandload.py @ 322:a0acae914e95

hgweb: Fix reloading of index -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hgweb: Fix reloading of index We were reloading every request because we weren't saving the old mtime. manifest hash: 507330727957ff53c48b38f427f0b70469a49271 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCreVpywK+sNU5EO8RAp/YAJ9cXh2II4DGAQtRc58yj4hi49C8jgCfT7bV 22w73T2FiYBjzMk8N8STUVI= =eghX -----END PGP SIGNATURE-----
author mpm@selenic.com
date Mon, 13 Jun 2005 11:58:33 -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