Giter VIP home page Giter VIP logo

django-classbasedsettings's People

Contributors

bennullgraham avatar jezdez avatar matthewwithanm avatar revolutiontech avatar rspeed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

django-classbasedsettings's Issues

Allow Repeat Registrations

Currently, settings classes can only be registered once. (An error is thrown if you register the same one twice.) However, this makes OR'ing rules needlessly difficult. If we relax this, it should be easier.

switcher.register(SettingsA, lambda: 'monkey' in __file__, lambda: 'dog' not in __file__)
switcher.register(SettingsA, lambda: 'monkey' not in __file__, lambda: 'dog' in __file__)

To accommodate this, we'll also have to change the internal representation from a SortedDict to a list so that effects of previous calls to register() aren't overridden.

Question: how to integrate with celery?

Is there a known way with making this work with celery when integrated with Django?

django-configurations seems to have a workaround, but when I try something similar, I think I'm getting circular import problems. Still trying to track it down ...

MetaClass Error When Extending PrefixedSettings and AppSettings

class A(AppSettings):
    pass

class P(PrefixedSettings):
    pass

class MySettings(A, P):
    pass

causes the following error:

TypeError: Error when calling the metaclass bases
metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Import error with Python 2.5

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/var/virtualenvs/topoftherocknyc.com/lib/python2.5/site-packages/cbsettings/__init__.py", line 9
    from .version import *
SyntaxError: 'import *' not allowed with 'from .'

Add Way to Specify Default Settings Class

To be used if none match. The mechanism we use will probably depend on what we decide for registration. Possibilities include the following:

class MySettings(object):
    SOME_SETTING = 'whatever'
    class Meta:
        default = True

@register(default=True)
class MySettings(object):
    SOME_SETTING = 'whatever'

django.conf.settings doesn't match switcher's settings

I'm having an odd problem -- my hiearchy is:

DjangoDefaults -> Base -> Dev -> myDev

DATABASES appears to reflect Dev not myDev.

When debugging,

ipdb> from django.conf import settings
ipdb> settings
<LazySettings "xxxx.config.factory_factory_unrolledcbsettings">

settings has DATABASES from Dev.

But if I look at xxxx.config.switcher_switcher_unrolledcbsettings

I get the right DATABASES.

....but why is one path switcher_switcher and the other factory_factory?

I have a switcher module, which just does:

switcher.register(rich.TestingSettings, hostnames=rich.HOSTNAMES, testing=True)
switcher.register(rich.RichDevelopmentSettings, hostnames=rich.HOSTNAMES, testing=False)

manage.py does:

    c = switcher()
    print("Settings: %s.%s" % (c.__module__, c.__class__.__name__))
    cbsettings.configure('xxxx.config.switcher.switcher')
    execute_from_command_line(sys.argv)

I commented out my manual call to switcher() above and no difference.

Any ideas?

Incompatible with Django 1.9

Django 1.7 deprecated django.utils.importlib and Django 1.9 dropped it.

Traceback (most recent call last):
  File "manage.py", line 5, in <module>
    import cbsettings
  File "/home/vagrant/.virtualenvs/flamingo/local/lib/python2.7/site-packages/cbsettings/__init__.py", line 2, in <module>
    from django.utils.importlib import import_module
ImportError: No module named importlib

I'm about to shoot you a pull request.

Allow Non-Callable Simple Checks

Currently, you have to do this:

switcher.register(MySettings, lambda: 'goforit' in __file__)

Let's make it so you can do this:

switcher.register(MySettings, 'goforit' in __file__)

In other words, check if the simple check is a callable before calling it. Simple!

FOO = Class gets instantiated

FOO=Class is a callable ... so Class gets called and instantiated into an object even though I really want the class instead.

Is there a workaround? Do I just need to make a lambda that returns the class?

I think does not work with Django 3.1

Somehow it thinks these are both defined:

django.core.exceptions.ImproperlyConfigured: PASSWORD_RESET_TIMEOUT_DAYS/PASSWORD_RESET_TIMEOUT are mutually exclusive.

And neither are in my code. I even tried setting one to None. I fear that Django has significantly changed their settings module so that there is a conflict now...

ImportError: No module named settings_factory_unrolledcbsettings

Hello there!

I'm having trouble running a project under gunicorn. It runs fine with manage.py runserver, but it breaks when I run gunicorn (Django==1.3.7, cbsettings==1.2.1).

Here's the full traceback:

013-05-20 23:27:00 [942] [INFO] Starting gunicorn 0.17.2
2013-05-20 23:27:00 [942] [INFO] Listening at: http://127.0.0.1:8000 (942)
2013-05-20 23:27:00 [942] [INFO] Using worker: sync
2013-05-20 23:27:00 [946] [INFO] Booting worker with pid: 946
2013-05-20 23:27:01 [946] [ERROR] Exception in worker process:
Traceback (most recent call last):
File "/Users/rlander/.virtualenvs/myapp/lib/python2.6/site-packages/gunicorn/arbiter.py", line 485, in spawn_worker
worker.init_process()
File "/Users/rlander/.virtualenvs/myapp/lib/python2.6/site-packages/gunicorn/workers/base.py", line 100, in init_process
self.wsgi = self.app.wsgi()
File "/Users/rlander/.virtualenvs/myapp/lib/python2.6/site-packages/gunicorn/app/base.py", line 103, in wsgi
self.callable = self.load()
File "/Users/rlander/.virtualenvs/myapp/lib/python2.6/site-packages/gunicorn/app/djangoapp.py", line 133, in load
return mod.make_command_wsgi_application(self.admin_media_path)
File "/Users/rlander/.virtualenvs/myapp/lib/python2.6/site-packages/gunicorn/app/django_wsgi.py", line 113, in make_command_wsgi_application
reload_django_settings()
File "/Users/rlander/.virtualenvs/myapp/lib/python2.6/site-packages/gunicorn/app/django_wsgi.py", line 54, in reload_django_settings
reload(mod)
ImportError: No module named settings_factory_unrolledcbsettings
Traceback (most recent call last):
File "/Users/rlander/.virtualenvs/myapp/lib/python2.6/site-packages/gunicorn/arbiter.py", line 485, in spawn_worker
worker.init_process()
File "/Users/rlander/.virtualenvs/myapp/lib/python2.6/site-packages/gunicorn/workers/base.py", line 100, in init_process
self.wsgi = self.app.wsgi()
File "/Users/rlander/.virtualenvs/myapp/lib/python2.6/site-packages/gunicorn/app/base.py", line 103, in wsgi
self.callable = self.load()
File "/Users/rlander/.virtualenvs/myapp/lib/python2.6/site-packages/gunicorn/app/djangoapp.py", line 133, in load
return mod.make_command_wsgi_application(self.admin_media_path)
File "/Users/rlander/.virtualenvs/myapp/lib/python2.6/site-packages/gunicorn/app/django_wsgi.py", line 113, in make_command_wsgi_application
reload_django_settings()
File "/Users/rlander/.virtualenvs/myapp/lib/python2.6/site-packages/gunicorn/app/django_wsgi.py", line 54, in reload_django_settings
reload(mod)
ImportError: No module named settings_factory_unrolledcbsettings

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.