Re: injecting settings

2019-05-09 Thread J. Pic
Maybe you would want to install an app without having their urls injected then you're going to need to do things like INSTALLED_APPS = [ someapp.AppConfig(urls=False) ] Of course this is going to make complicate the settings system, but why not hook a callback in AppConfig that is executed i

Re: injecting settings

2019-05-09 Thread Christian González
> > It looks like app maintainers really ought to give django-gdaps a > shot. Perhaps Christian, another way would be to contribute gdap > support to the apps you like to use in the ecosystem. Then their > maintainers could benefit from it if they install gdaps and so it can > propagate in the eco

Re: injecting settings

2019-05-09 Thread J. Pic
In the example Config.ready() calls for a dict update() which will probably work for a while, before changing the update() call in the example with more elaborated code. System checks shoud catch cases where configuration is invalid at all. Not sure how much you can pull from entry points, if you

Re: injecting settings

2019-05-09 Thread J. Pic
ERRATA in the code above, a mistake I make really often, instead of: DebugToolbarMiddleware = debug_toolbar.middleware.DebugToolbarMiddleware Should be: DebugToolbarMiddleware = debug_toolbar.middleware:DebugToolbarMiddleware In one python module I rely on this (cli2), I ended just making so th

Re: injecting settings

2019-05-08 Thread Dan Davis
> Another thing to possibly consider, what should happen if multiple > packages try to provide different defaults for the same setting? I > mean, of course, this has kind of been floated in this thread already, > but it would add one more item to the list of things affected by the > order of INSTAL

Re: injecting settings

2019-05-08 Thread Aymeric Augustin
> On 8 May 2019, at 11:38, Michal Petrucha wrote: > > On Tue, May 07, 2019 at 10:53:37PM +0200, Aymeric Augustin wrote: >> If we're only talking about providing default values for settings, currently >> there are two straightforward solutions: >> >> 1. Like Adam suggested, access settings like

Re: injecting settings

2019-05-08 Thread Michal Petrucha
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hi folks, On Tue, May 07, 2019 at 10:53:37PM +0200, Aymeric Augustin wrote: > If we're only talking about providing default values for settings, currently > there are two straightforward solutions: > > 1. Like Adam suggested, access settings like

Re: injecting settings

2019-05-07 Thread Dan Davis
Christian, I do this in my internal and private module that depends on django-cas-ng. django-cas-ng provides default settings in an __init__.py file that predates app.py and ready. My strategy is that if you wish to depend on another app in this way, it is best to shadow it entirely. For exam

Re: injecting settings

2019-05-07 Thread Tom Forbes
I think what you are describing is a hard problem(tm) with no clear and generic way to solve it. Django doesn’t have the concept of a dependency tree in apps, and while this is annoying in some cases there isn’t much we can do to solve it. If I understand your proposition, it would inevitably in

Re: injecting settings

2019-05-07 Thread Christian González
Sorry about writing, and not testing myself before: > 2. Set a default value at import time: > > # apps.py > > from django.apps import AppConfig > from django.conf import settings > > class MyAppConfig(AppConfig): >     name = 'my_app' >     verbose_name = "..." > >     def ready(self): >        

Re: injecting settings

2019-05-07 Thread Christian González
> 1. Like Adam suggested, access settings like this: getattr(settings, > 'MY_SETTING', 'my_default'). > > This works well when you access settings just once, probably at import > time, and cache their value. > > Here's an > example:  > https://github.com/aaugustin/django-sesame/blob/070cdb3fcdfa6c

Re: injecting settings

2019-05-07 Thread Aymeric Augustin
> On 7 May 2019, at 17:49, Christian González > wrote: > Apps should have the possibility to add DEFAULT settings to the Django global > settings. As already mentioned in my plugin system question, I don't see a > problem with app/settings loading order. The loading order is done in > INSTALLE

Re: injecting settings

2019-05-07 Thread Christian González
Hi Americ, thanks for answering THAT elaborative (I first thought that it#s a typical newbie question). > > When you say this is not possible, I assume you are referring to my > work on app-loading in Django 1.7. Here's what comes to mind. Yes. > [...] > > Finally, this would mean that pluggable

Re: injecting settings

2019-05-07 Thread Aymeric Augustin
Hello Christian, I'm not aware of any plans in this area. When you say this is not possible, I assume you are referring to my work on app-loading in Django 1.7. Here's what comes to mind. There's a chicken'n'egg problems if an app modifies INSTALLED_APPS during app loading. This is a common idea

Re: injecting settings

2019-05-07 Thread Adam Johnson
If your django apps have default settings, they can use getattr(settings, 'MY_VALUE', default) For third party apps I've often used an object with a bit of logic to encapsulate these defaults, especially useful in the face of app changes. For example: https://github.com/adamchainz/nexus/blob/maste

Re: injecting settings

2019-05-07 Thread Carlton Gibson
Also see the django-appconf app: https://github.com/django-compressor/django-appconf This is used by django-compressor (hence it's home) and others to add (and allow overriding) per-app settings. -- You received this message because you are subscribed to the Google Groups "Django developers

Re: injecting settings

2019-05-07 Thread Christian González
I myself am using an implementation like DRF does it: https://github.com/encode/django-rest-framework/blob/e16273a6584f9657c1e5c388558e9c5c92e7ba38/rest_framework/settings.py They create a class "APISettings", and mimic the Django behaviour. Dand graphene-django has adapted it already and change

Re: injecting settings

2019-05-07 Thread J. Pic
Great idea Christian, actually some frameworks have this kind of feature, such as CakePHP, in which apps can also inject urls and middlewares for example. This would be a huge step forward for the ecosystem (and when apps can share node modules you're done haha !). -- You received this message b

injecting settings

2019-05-07 Thread Christian González
Hi, I know this is a bit of a question half development, half usage of django. I'd like to create an django app which has sub apps which inject automatic code into settings. This is not possible, as the docs say. Are there plans in development to enable that? It's not necessary to "change" setti