django.contrib.auth.load_backend()
django.core.files.storage.get_storage_class()
django.template.loader.find_template_loader()
django.db.load_backend()
Database loaders are a bit of an oddball, since they load an entire
module's worth of classes based on the setting, but there's repetition
even there. Unfortunately, I can't dedicate much of my own time at the
moment to look into this, but I think it'd be worth doing before we
start adding even more features with configurable backends in the
future.
-Marty
Also, django.core.cache.get_cache
Also django.core.email, django.contrib.messages,
django.contrib.sessions... the list goes on.
The difficulty is that they aren't all exactly the same:
* The email backend loader take arguments that configure the
underlying mail connection
* The cache backend needs to handle a URI-style definition.
* The template loaders need to have fallback support for old-style
template loaders, as well as handling checks for whether the loader is
available in the current environment.
Similar eccentricities exist in many of the backends.
In short - yes, factoring this out into a common utility is desirable.
However, it's a lot easier said than done.
Yours,
Russ Magee %-)
Yup - and as I copied and pasted it from somewhere else I thought
exactly the same thing. Is this kind of refactoring something we can
do after the 1.2 feature freeze? If so I think it would be worth
cleaning up at least some of this stuff.
Cheers,
Simon
Absolutely, this is completely separate from anything that should
affect the feature freeze. As Russ pointed out, there are a lot of
different of this backend loading stuff, so it'll be tricky to figure
out just how much can/should be factored out, how to deal with some of
the variations and how to recommend people do it going forward. In
fact, it's not even something that needs to happen by the 1.2 release
at all, if more time is necessary to get it right. It's less than
ideal at the moment, but I'd say practicality beats purity in this
case, to make sure we can get the goods out the door.
-Marty