Did I find the right examples for you? yes no

All Samples(8)  |  Call(4)  |  Derive(0)  |  Import(4)
Loads a class given a class_path. The setting value may be a string or a
tuple.

The setting_name parameter is only there for pretty error output, and
therefore is optional

        def load_class(class_path, setting_name=None):
    """
    Loads a class given a class_path. The setting value may be a string or a
    tuple.

    The setting_name parameter is only there for pretty error output, and
    therefore is optional
    """
    if not isinstance(class_path, basestring):
        try:
            class_path, app_label = class_path
        except:
            if setting_name:
                raise exceptions.ImproperlyConfigured(CLASS_PATH_ERROR % (
                    setting_name, setting_name))
            else:
                raise exceptions.ImproperlyConfigured(CLASS_PATH_ERROR % (
                    'this setting', 'It'))

    try:
        class_module, class_name = class_path.rsplit('.', 1)
    except ValueError:
        if setting_name:
            txt = '%s isn\'t a valid module. Check your %s setting' % (
                class_path, setting_name)
        else:
            txt = '%s isn\'t a valid module.' % class_path
        raise exceptions.ImproperlyConfigured(txt)

    try:
        mod = import_module(class_module)
    except ImportError, e:
        if setting_name:
            txt = 'Error importing backend %s: "%s". Check your %s setting' % (
                class_module, e, setting_name)
        else:
            txt = 'Error importing backend %s: "%s".' % (class_module, e)

        raise exceptions.ImproperlyConfigured(txt)

    try:
        clazz = getattr(mod, class_name)
    except AttributeError:
        if setting_name:
            txt = ('Backend module "%s" does not define a "%s" class. Check'
                   ' your %s setting' % (class_module, class_name,
                                         setting_name))
        else:
            txt = 'Backend module "%s" does not define a "%s" class.' % (
                class_module, class_name)
        raise exceptions.ImproperlyConfigured(txt)
    return clazz
        


src/d/j/django-leetchi-0.1.10/djleetchi/helpers.py   django-leetchi(Download)
from django.core.exceptions import ImproperlyConfigured
 
from .util import load_class
 
 
    raise ImproperlyConfigured('The required setting **LEETCHI_PAYER_HELPER** is missing.')
elif isinstance(get_payer, six.string_types):
    get_payer = load_class(get_payer)
 
 
    raise ImproperlyConfigured('The required setting **LEETCHI_WALLET_HELPER** is missing.')
elif isinstance(get_wallet, six.string_types):
    get_wallet = load_class(get_wallet)
 

src/d/j/django-redis-3.6.1/redis_cache/cache.py   django-redis(Download)
from django.core.cache import get_cache
 
from .util import load_class
from .exceptions import ConnectionInterrupted
 
        options = params.get("OPTIONS", {})
        self._client_cls = options.get("CLIENT_CLASS", "redis_cache.client.DefaultClient")
        self._client_cls = load_class(self._client_cls)
        self._client = None
 

src/d/j/django-redis-HEAD/redis_cache/cache.py   django-redis(Download)
from django.core.cache.backends.base import BaseCache
 
from .util import load_class
from .exceptions import ConnectionInterrupted
 
        options = params.get("OPTIONS", {})
        self._client_cls = options.get("CLIENT_CLASS", "redis_cache.client.DefaultClient")
        self._client_cls = load_class(self._client_cls)
        self._client = None
 

src/d/j/django-redis-3.6.1/redis_cache/client/default.py   django-redis(Download)
                              UnixDomainSocketConnection)
 
from ..util import CacheKey, load_class, integer_types
from ..exceptions import ConnectionInterrupted