def get_supplement_class(path=None): """ Return an instance of a registration supplement, given the dotted Python import path (as a string) to the supplement class. If the addition cannot be located (e.g., because no such module exists, or because the module does not contain a class of the appropriate name), ``django.core.exceptions.ImproperlyConfigured`` is raised. """ from registration.conf import settings path = path or settings.REGISTRATION_SUPPLEMENT_CLASS if not path: return None i = path.rfind('.') module, attr = path[:i], path[i + 1:] try: mod = import_module(module) except ImportError as e: raise ImproperlyConfigured( 'Error loading registration addition %s: "%s"' % (module, e)) try: cls = getattr(mod, attr) except AttributeError: raise ImproperlyConfigured( ('Module "%s" does not define a registration supplement named ' '"%s"') % (module, attr)) from registration.supplements.base import RegistrationSupplementBase if cls and not issubclass(cls, RegistrationSupplementBase): raise ImproperlyConfigured( ('Registration supplement class "%s" must be a subclass of ' '``registration.supplements.RegistrationSupplementBase``') % path) return cls
def get_supplement_admin_inline_base_class(path=None): """ Return a class of a admin inline class for registration supplement, given the dotted Python import path (as a string) to the admin inline class. If the addition cannot be located (e.g., because no such module exists, or because the module does not contain a class of the appropriate name), ``django.core.exceptions.ImproperlyConfigured`` is raised. """ path = path or settings.REGISTRATION_SUPPLEMENT_ADMIN_INLINE_BASE_CLASS i = path.rfind('.') module, attr = path[:i], path[i + 1:] try: mod = import_module(module) except ImportError as e: raise ImproperlyConfigured( ('Error loading admin inline class for registration supplement ' '%s: "%s"') % (module, e)) try: cls = getattr(mod, attr) except AttributeError: raise ImproperlyConfigured( ('Module "%s" does not define a admin inline class for ' 'registration supplement named "%s"') % (module, attr)) if cls and not issubclass(cls, RegistrationSupplementAdminInlineBase): raise ImproperlyConfigured( ('Admin inline class for registration supplement class "%s" ' 'must be a subclass of ``registration.admin.' 'RegistrationSupplementAdminInlineBase``') % path) return cls
def get_backend_class(path=None): """ Return an class of a registration backend, given the dotted Python import path (as a string) to the backend class. If the backend cannot be located (e.g., because no such module exists, or because the module does not contain a class of the appropriate name), ``django.core.exceptions.ImproperlyConfigured`` is raised. """ path = path or settings.REGISTRATION_BACKEND_CLASS i = path.rfind('.') module, attr = path[:i], path[i+1:] try: mod = import_module(module) except ImportError as e: raise ImproperlyConfigured( 'Error loading registration backend %s: "%s"' % (module, e)) try: cls = getattr(mod, attr) except AttributeError: raise ImproperlyConfigured(( 'Module "%s" does not define a registration backend named "%s"' ) % (module, attr)) if cls and not issubclass(cls, RegistrationBackendBase): raise ImproperlyConfigured(( 'Registration backend class "%s" must be a subclass of ' '``registration.backends.RegistrationBackendBase``') % path) return cls
def get_supplement_class(path=None): """ Return an instance of a registration supplement, given the dotted Python import path (as a string) to the supplement class. If the addition cannot be located (e.g., because no such module exists, or because the module does not contain a class of the appropriate name), ``django.core.exceptions.ImproperlyConfigured`` is raised. """ from registration.conf import settings path = path or settings.REGISTRATION_SUPPLEMENT_CLASS if not path: return None i = path.rfind('.') module, attr = path[:i], path[i+1:] try: mod = import_module(module) except ImportError as e: raise ImproperlyConfigured( 'Error loading registration addition %s: "%s"' % (module, e)) try: cls = getattr(mod, attr) except AttributeError: raise ImproperlyConfigured(( 'Module "%s" does not define a registration supplement named ' '"%s"') % (module, attr)) if cls and not issubclass(cls, RegistrationSupplementBase): raise ImproperlyConfigured(( 'Registration supplement class "%s" must be a subclass of ' '``registration.supplements.RegistrationSupplementBase``') % path) return cls
def get_backend_class(path=None): """ Return an class of a registration backend, given the dotted Python import path (as a string) to the backend class. If the backend cannot be located (e.g., because no such module exists, or because the module does not contain a class of the appropriate name), ``django.core.exceptions.ImproperlyConfigured`` is raised. """ path = path or settings.REGISTRATION_BACKEND_CLASS i = path.rfind('.') module, attr = path[:i], path[i+1:] try: mod = import_module(module) except ImportError, e: raise ImproperlyConfigured( 'Error loading registration backend %s: "%s"' % (module, e))
def get_supplement_admin_inline_base_class(path=None): """ Return a class of a admin inline class for registration supplement, given the dotted Python import path (as a string) to the admin inline class. If the addition cannot be located (e.g., because no such module exists, or because the module does not contain a class of the appropriate name), ``django.core.exceptions.ImproperlyConfigured`` is raised. """ path = path or settings.REGISTRATION_SUPPLEMENT_ADMIN_INLINE_BASE_CLASS i = path.rfind('.') module, attr = path[:i], path[i + 1:] try: mod = import_module(module) except ImportError, e: raise ImproperlyConfigured( ('Error loading admin inline class for registration supplement ' '%s: "%s"') % (module, e))
def get_supplement_admin_inline_base_class(path=None): """ Return a class of a admin inline class for registration supplement, given the dotted Python import path (as a string) to the admin inline class. If the addition cannot be located (e.g., because no such module exists, or because the module does not contain a class of the appropriate name), ``django.core.exceptions.ImproperlyConfigured`` is raised. """ path = path or settings.REGISTRATION_SUPPLEMENT_ADMIN_INLINE_BASE_CLASS i = path.rfind('.') module, attr = path[:i], path[i+1:] try: mod = import_module(module) except ImportError, e: raise ImproperlyConfigured(( 'Error loading admin inline class for registration supplement ' '%s: "%s"') % (module, e))
def get_supplement_class(path=None): """ Return an instance of a registration supplement, given the dotted Python import path (as a string) to the supplement class. If the addition cannot be located (e.g., because no such module exists, or because the module does not contain a class of the appropriate name), ``django.core.exceptions.ImproperlyConfigured`` is raised. """ from registration.conf import settings path = path or settings.REGISTRATION_SUPPLEMENT_CLASS if not path: return None i = path.rfind('.') module, attr = path[:i], path[i+1:] try: mod = import_module(module) except ImportError, e: raise ImproperlyConfigured( 'Error loading registration addition %s: "%s"' % (module, e))
def get_supplement_class(path=None): """ Return an instance of a registration supplement, given the dotted Python import path (as a string) to the supplement class. If the addition cannot be located (e.g., because no such module exists, or because the module does not contain a class of the appropriate name), ``django.core.exceptions.ImproperlyConfigured`` is raised. """ from registration.conf import settings path = path or settings.REGISTRATION_SUPPLEMENT_CLASS if not path: return None i = path.rfind('.') module, attr = path[:i], path[i + 1:] try: mod = import_module(module) except ImportError, e: raise ImproperlyConfigured( 'Error loading registration addition %s: "%s"' % (module, e))
def get_supplement_admin_inline_base_class(path=None): """ Return a class of a admin inline class for registration supplement, given the dotted Python import path (as a string) to the admin inline class. If the addition cannot be located (e.g., because no such module exists, or because the module does not contain a class of the appropriate name), ``django.core.exceptions.ImproperlyConfigured`` is raised. """ path = path or settings.REGISTRATION_SUPPLEMENT_ADMIN_INLINE_BASE_CLASS i = path.rfind('.') module, attr = path[:i], path[i+1:] try: mod = import_module(module) except ImportError as e: raise ImproperlyConfigured(( 'Error loading admin inline class for registration supplement ' '%s: "%s"' ) % (module, e)) try: cls = getattr(mod, attr) except AttributeError: raise ImproperlyConfigured(( 'Module "%s" does not define a admin inline class for ' 'registration supplement named "%s"' ) % (module, attr)) if cls and not issubclass(cls, RegistrationSupplementAdminInlineBase): raise ImproperlyConfigured(( 'Admin inline class for registration supplement class "%s" ' 'must be a subclass of ``registration.admin.' 'RegistrationSupplementAdminInlineBase``' ) % path) return cls