class AdminSite(object): def __init__(self, name='admin'): self._registry = {} def register(self, model,**options): self._registry[model] = model() site=AdminSite()
from sites import site class Dog(object): pass site.register(Dog) print(site._registry)
from sites import site class Pig(object): pass site.register(Pig) print(site._registry)
if __name__ == '__main__': from app01 import admin as admin01 from app02 import admin as admin02