diff options
| author | Ben Firshman | 2010-01-25 01:00:07 +0000 |
|---|---|---|
| committer | Ben Firshman | 2014-09-21 17:08:55 -0700 |
| commit | c22f6b46e9faecc4d83c6dc575f0179796fc0c1e (patch) | |
| tree | 95568dfcbd0f8aab24020f37b353aad4cbe484d0 /src/shorturls/__init__.py | |
| parent | eb1e1c2feddb282c74dc597c4f51c5ccfe5c7fe1 (diff) | |
| download | django-shorturls-c22f6b46e9faecc4d83c6dc575f0179796fc0c1e.tar.bz2 | |
Added SHORTURLS_DEFAULT_CONVERTER setting so template tag converter can be specified
Diffstat (limited to 'src/shorturls/__init__.py')
| -rw-r--r-- | src/shorturls/__init__.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/shorturls/__init__.py b/src/shorturls/__init__.py index e69de29..528e838 100644 --- a/src/shorturls/__init__.py +++ b/src/shorturls/__init__.py @@ -0,0 +1,19 @@ +from django.conf import settings +from django.core.exceptions import ImproperlyConfigured +from django.utils.importlib import import_module +from shorturls import baseconv + +default_converter = baseconv.base62 + +if hasattr(settings, 'SHORTURLS_DEFAULT_CONVERTER'): + mod_name, conv_name = settings.SHORTURLS_DEFAULT_CONVERTER.rsplit('.', 1) + try: + mod = import_module(mod_name) + except ImportError, e: + raise ImproperlyConfigured('Could not load converter specified by SHORTURLS_DEFAULT_CONVERTER. Error was: %s' % e) + try: + default_converter = getattr(mod, conv_name) + except AttributeError: + raise ImproperlyConfigured('Could not load converter specified by SHORTURLS_DEFAULT_CONVERTER. %s is not in %s.' % (conv_name, mod)) + +
\ No newline at end of file |
