Ticket #12012: 12012-r11620.diff

File 12012-r11620.diff, 1.5 KB (added by Vinay Sajip, 13 years ago)

Patch to show how both logging and class_prepared listening can be done via setting.py

  • django/conf/__init__.py

     
    8585                    setting_value = (setting_value,) # In case the user forgot the comma.
    8686                setattr(self, setting, setting_value)
    8787
     88        if hasattr(self, 'BOOTSTRAP_CALLBACKS'):
     89            try:
     90                callbacks = self.BOOTSTRAP_CALLBACKS
     91                for callback in callbacks:
     92                    try:
     93                        callback()
     94                    except Exception:
     95                        raise # TODO handle error in callback
     96            except TypeError:
     97                raise # TODO handle non-iterable
     98
    8899        # Expand entries in INSTALLED_APPS like "django.contrib.*" to a list
    89100        # of all those apps.
    90101        new_installed_apps = []
  • django/db/models/loading.py

     
    5252        try:
    5353            if self.loaded:
    5454                return
     55
     56            if hasattr(settings, 'PRE_MODEL_CALLBACKS'):
     57                callbacks = settings.PRE_MODEL_CALLBACKS
     58                for callback in callbacks:
     59                    callback()
     60
    5561            for app_name in settings.INSTALLED_APPS:
    5662                if app_name in self.handled:
    5763                    continue
Back to Top