def register(self, model, registry_class=None): """ Registers a model with the site. The model should be a Model class, not instances. If no registry_class is provided CoreRegistry will be applied to the model. """ if not registry_class: from tendenci.core.registry.base import CoreRegistry registry_class = CoreRegistry if not hasattr(model, '_meta'): raise AttributeError( _('The model being registered must derive from Model.')) if model in self._registry: raise AlreadyRegistered( _('The model %(cls)s is already registered' % {'cls': model.__class__})) self._registry[model] = registry_class(model) #reset cache of the registered apps delete_reg_apps_cache() cache_reg_apps(self.get_registered_apps())
def unregister(self, model): """ Unregisters a model from the site. """ if model not in self._registry: raise NotRegistered(_('The model %(cls)s is not registered' % {'cls' :model.__class__})) del(self._registry[model]) #reset cache of the registered apps delete_reg_apps_cache() cache_reg_apps(self.get_registered_apps())
def unregister(self, model): """ Unregisters a model from the site. """ if model not in self._registry: raise NotRegistered('The model %s is not registered' % model.__class__) del (self._registry[model]) #reset cache of the registered apps delete_reg_apps_cache() cache_reg_apps(self.get_registered_apps())
def register(self, model, registry_class=None): """ Registers a model with the site. The model should be a Model class, not instances. If no registry_class is provided CoreRegistry will be applied to the model. """ if not registry_class: from tendenci.core.registry.base import CoreRegistry registry_class = CoreRegistry if not hasattr(model, '_meta'): raise AttributeError(_('The model being registered must derive from Model.')) if model in self._registry: raise AlreadyRegistered(_('The model %(cls)s is already registered' % {'cls' :model.__class__})) self._registry[model] = registry_class(model) #reset cache of the registered apps delete_reg_apps_cache() cache_reg_apps(self.get_registered_apps())