Code Monkey home page Code Monkey logo

Comments (4)

cinnabot avatar cinnabot commented on May 16, 2024

Hi, I have some suggestions to help solving this issue!

Here is a list of similar issues:

  1. Defining default values for some configuration parameters.

  2. Allow separation of projects vars via namespace

Please let me know if this was useful:

Cheers,
Cinnabot.

PS: Liked my suggestions? Install me in your repository! Visit: getcinnamon.io.

from dynaconf.

rochacbruno avatar rochacbruno commented on May 16, 2024

It was like that before, users needed to call settings.configure before accessing variables.

But some users wanted to have the default namespace for the reasons I commented in #23 (default namespace is needed to define global values)

You change the default namespace name of global namespace using DYNACONF_NAMESPACE env var.

Maybe we can introduce a new object which does not load, for example.

from dynaconf import lazy_settings as settings
settings.namespace('devel')

That new object will be the same, the only difference is that it is not configured automatically and requires settings.namespace to be called once.

from dynaconf.

vladcalin avatar vladcalin commented on May 16, 2024

That would be awesome! Let me know if I can help :)

from dynaconf.

rochacbruno avatar rochacbruno commented on May 16, 2024

I am closing this one year old issue because many things changed since it was created.

Dynaconf exists to avoid the need for such if sys.argv[1] == "prod": kind of code, dynaconf has the goal to make it dynamic by choosing the env based on environment_variables or specific settings passed to LazySettings class.

For your use case the solution is

project/conf.py

from dynaconf import LazySettings
settings = LazySettings(NAMESPACE_FOR_DYNACONF=sys.argv[1])

project/app.py dev

from .conf import settings

settings.current_namespace == 'DEV'

However this case is not recommended, the better by 12 factor apps guide is doing

Your env shell

export NAMESPACE_FOR_DYNACONF=dev

or direct in program call

NAMESPACE_FOR_DYNACONF=dev program/app.py

from dynaconf import settings
settings.current_namespace == 'DEV'

The use of environment variables is better and widely used

from dynaconf.

Related Issues (20)

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.