--Lately I implemented some changes for django's settings module .I refactored the whole module in order to have more extension points.With #20040 it is now possible to inject the Settings class that will be used by the LazySettings object and I introduced a new class called SettingsCollector that allows the developer to costumize how django will collect it's settings.This enabled me to write the real code that will allow loading the settings either as a package or as a module.Instead of having one big monolitic settings.py you can now have a package that has configuration modules that are seperated by topic.If #20040 is accepted I can work on the new SettingsCollector that will either try to load a settings module or package.Should the new default be a package or a module? If it's a package it means we should also change the project_template.This is the working prototype that I wrote before I thought about creating a new SettingsCollector class.To test it just call monkey_patch() in your manage.py.We might want to allow multiple modules and packages to be loaded.This will help us actually use the settings_local.py in a standard way.What do you guys think? Am I clear enoguh? Should I explain in more detail what am I thinking here?
You received this message because you are subscribed to the Google Groups "Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
I find the value of separate settings modules is not splitting them by topic, but overriding them in specific contexts, like staging, production and development. Your implementation (and, I think, any solution that compiles multiple settings modules independently) don't have a way to specify orderings in a non-magical way. That's why I prefer explicitly importing some common settings into one module and overriding them piecemeal. The Zen of Python says "Explicit is better than implicit" and I think that is the case here. Packages provide settings and reasonable defaults. If you want to modularize them, you are free to do so yourself. I think composing settings internally is just added complexity for little benefit.
--
Why would you call them magic?Why does allowing extensibility for those who need it is a bad idea?You will be doing it explicitly anyway by providing a SettingsCollector class to the Settings class' constructor.If are doing it, you should know what you are doing.. Is my code harder to debug or understand than the current code? I strongly disagree here. The current Settings class clearly violates SRP. It holds the settings, validates them and collect them. What's not easy to understand about SettingsCollector? You can understand by it's name what exactly it does."The only reason for having these SettingsCollectors in core is to allow redistributable apps like django-configurations to do magic. That is, so they can say, "Install django-configurations, and suddenly every setting can be overridden from the environment!" This seems like a bad idea, versus "Install django-configurations, and now you have a new tool in your toolbox to put in settings.py that imports from the environment!""Why exactly this is a bad idea? Since when extensibility is a bad idea in software development?You just say you are against it but you don't provide a good reason other than it's easier to explain to others what's wrong if something is wrong.The current behavior will stay as the default behavior at least until Django 2.0 if not forever so "it's easier to explain to others what's wrong" is not a valid argument in my opinion.If you are writing your own SettingsCollector you probably know what you are doing.If we'll introduce other types of SettingsCollectors in Django then we won't introduce them in the Getting Started documentation until a very late stage so that newcomers can understand the default behavior but that's another issue for later on.For now I want to focus on the pull request itself.Does the refactoring makes the code clearer in it's intension?Does it allow extensibility when it is required?Does it maintain the default behavior for most Django developers?I believe that the answer to all of those questions is yes it does.
--
You received this message because you are subscribed to a topic in the Google Groups "Django developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-developers/1M5nfnpba0M/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to django-develop...@googlegroups.com.
You received this message because you are subscribed to the Google Groups "Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Django developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-developers/1M5nfnpba0M/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to django-develop...@googlegroups.com.
You are contradicting yourself. At first you said that it does make the code clearer. Now you say it doesn't.
Ok, you guys are right. I'm adding a new feature.If you think my new design isn't good enough do tell me why. I'll improve it/change it completely.It now doesn't violate SRP, it allows flexability for those who need it and maintains backward competitability. What else is missing here?I feel a bit like a broken record here because I did specify over and over what's the purpose of this change.I don't want to load settings from a class. I'd like to provide extensibiloty points in order to help implemet other workflows that people use.
The purpose of this patch is to:
- Allow developers to implement different workflows for loading settings for different environments (class based settings, different modules, different packages).
- Allow developers to load settings from other sources like django-debian does.
- Allow developers to change settings as they are collected (for example django-harness does multiple things like this).
There are usecases, some people actually implemented those outside of the framework and I don't see a reason why they should. We're perfectionists with deadlines right? There's no reason to write django-configurations if in five minutes you can get the same result out of the box.Do you see value in django-configurations, django-debian or django-harness?
Then you must see the value in this patch. You can implement all of those in an hour tops including documentation and tests with it.If you don't, just keep using the default behavior. No harm done.What exactly is the maintainance burden here?
Instead of saying "Check the DJANGO_SETTINGS_MODULE" you now just need to ask "Have you written a new collector or loader? No? Check the DJANGO_SETTINGS_MODULE".You want to change how settings are being loaded by default? How does that contradict the use of my patch?In fact it makes it much easier because now you can just rewrite the collector and loader and you have a new default way of loading settings.I know there were talks about changing how settings behave and that's why I did something about it.
Am I clear enough now?
--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
On Sun, Mar 24, 2013 at 6:28 PM, Omer Katz <omer...@gmail.com> wrote:You are contradicting yourself. At first you said that it does make the code clearer. Now you say it doesn't.My apologies -- I've apparently used an English idiom that doesn't have an obvious meaning.When I said "I'd argue the point that it makes the code clearer", that means "You said it was clearer, I disagree, and I'd be willing to defend my position."I do not believe that your proposed patch makes the code clearer.Ok, you guys are right. I'm adding a new feature.If you think my new design isn't good enough do tell me why. I'll improve it/change it completely.It now doesn't violate SRP, it allows flexability for those who need it and maintains backward competitability. What else is missing here?
I feel a bit like a broken record here because I did specify over and over what's the purpose of this change.I don't want to load settings from a class. I'd like to provide extensibiloty points in order to help implemet other workflows that people use.And at this point, I'm also feeling like a broken record. The point that I, and several other people have made repeatedly is that we fail to see how these extensibility points would be used in practice. You haven't demonstrated a use case where what you describe would be helpful.Saying "It makes it easier to implement django-configurations" isn't a use case. A use case here might be "it makes it easier to define the development/production settings split".
The purpose of this patch is to:
- Allow developers to implement different workflows for loading settings for different environments (class based settings, different modules, different packages).
- Allow developers to load settings from other sources like django-debian does.
- Allow developers to change settings as they are collected (for example django-harness does multiple things like this).
There are usecases, some people actually implemented those outside of the framework and I don't see a reason why they should. We're perfectionists with deadlines right? There's no reason to write django-configurations if in five minutes you can get the same result out of the box.Do you see value in django-configurations, django-debian or django-harness?In short? No.
Adding an extensibility point is only beneficial if you actually want that particular axis to be extensible. It's good that Django has an extensibility point for database backends -- that allows someone outside core to develop a backend for DB2 or MSSQL.However, I don't see the benefit in having an extensible mechanism for defining settings. Settings are settings. There should be *one* way to define them, and that's it. There's *benefit* in there only being one way to define settings, because that means that someone coming to a project for doesn't need to discover, and then learn, about a whole other way of defining the fundamental feature the settings for a Django project.
Are the problems with Django's settings framework? Yes. Are there areas that would benefit from more documented "best practice" conventions? Absolutely. Does any of this require a flexible framework for altering the way Django loads settings? Not as far as I can make out.
Then you must see the value in this patch. You can implement all of those in an hour tops including documentation and tests with it.If you don't, just keep using the default behavior. No harm done.What exactly is the maintainance burden here?There is code that can break. There is a publicly documented interface that, once added, we must support into the future. If we ever want to make a change to the way settings are handled (and we do, if you watch the video I linked), we would also need to support this interface going forward. Once a new feature is added, someone may ask for additional tweaks to that feature. Someone may attempt to use that interface in an unconventional way, forcing us to work out whether that usage is supported or not.And on top of all of that, we're fracturing the community position on "how do you define settings". Instead of being able to tell someone, "go look in settings.py", we have to say "Go find out what settings loading mechanism the project has, and then consult the documentation on that".*That* is the maintenance burden.Instead of saying "Check the DJANGO_SETTINGS_MODULE" you now just need to ask "Have you written a new collector or loader? No? Check the DJANGO_SETTINGS_MODULE".You want to change how settings are being loaded by default? How does that contradict the use of my patch?In fact it makes it much easier because now you can just rewrite the collector and loader and you have a new default way of loading settings.I know there were talks about changing how settings behave and that's why I did something about it.Am I clear enough now?What is clear to me is that you would like to use django-configurations (or an analog of it).My question to you -- Why do you want to use django-configurations in the first place? What problem is it solving? Then lets focus on solving *that* problem. I'd be very much surprised if the solution involves introducing a pluggable mechanism for loading settings.
Yours,Russ Magee %-)