def setup(cls):
     for name, value in uppercase_attributes(cls).items():
         if isinstance(value, Value):
             try:
                 setup_value(cls, name, value)
             except ValueError, e:
                 print 'WARNING: ', e
Exemplo n.º 2
0
def FileSettings(path):
    path = os.path.expanduser(path)
    mod = imp.new_module('localshop.local')
    mod.__file__ = path

    class Holder(object):
        pass

    try:
        with open(path, 'r') as fh:
            exec(fh.read(), mod.__dict__)
    except IOError as e:
        print("Notice: Unable to load configuration file %s (%s), "
              "using default settings\n\n" % (path, e.strerror))
        return Holder

    for name, value in uppercase_attributes(mod).items():
        setattr(Holder, name, value)

    return Holder
Exemplo n.º 3
0
def FileSettings(path):
    path = os.path.expanduser(path)
    mod = imp.new_module('localshop.local')
    mod.__file__ = path

    class Holder(object):
        pass

    try:
        with open(path, 'r') as fh:
            exec(fh.read(), mod.__dict__)
    except IOError as e:
        print("Notice: Unable to load configuration file %s (%s), "
              "using default settings\n\n" % (path, e.strerror))
        return Holder

    for name, value in uppercase_attributes(mod).items():
        setattr(Holder, name, value)

    return Holder
Exemplo n.º 4
0
def apply_settings(cls):
    """A decorator to set class attributes from imported settings."""
    for key, value in uppercase_attributes(settings).items():
        setattr(cls, key, value)
    return cls
Exemplo n.º 5
0
def FileSettings(path):
    path = os.path.expanduser(path)
    mod = imp.new_module('localshop.local')
    mod.__file__ = path

    class Holder(object):
        pass

    try:
        execfile(path, mod.__dict__)
    except IOError, e:
        print("Notice: Unable to load configuration file %s (%s), "
              "using default settings\n\n" % (path, e.strerror))
        return Holder

    for name, value in uppercase_attributes(mod).items():
        setattr(Holder, name, value)

    return Holder


class Base(Settings):
    # Django settings for localshop project.
    PROJECT_ROOT = os.path.join(os.path.dirname(__file__), os.pardir)

    DEBUG = False
    TEMPLATE_DEBUG = DEBUG

    ADMINS = (
        # ('Your Name', '*****@*****.**'),
    )
Exemplo n.º 6
0
def FileSettings(path):
    path = os.path.expanduser(path)
    mod = imp.new_module('localshop.local')
    mod.__file__ = path

    class Holder(object):
        pass

    try:
        execfile(path, mod.__dict__)
    except IOError, e:
        print("Notice: Unable to load configuration file %s (%s), "
              "using default settings\n\n" % (path, e.strerror))
        return Holder

    for name, value in uppercase_attributes(mod).items():
        setattr(Holder, name, value)

    return Holder


class Base(Settings):
    # Django settings for localshop project.
    PROJECT_ROOT = os.path.join(os.path.dirname(__file__), os.pardir)

    DEBUG = False
    TEMPLATE_DEBUG = DEBUG

    ADMINS = (
        # ('Your Name', '*****@*****.**'),
    )