The INI file is just a convenience for developers who like that format. Putting 'pyramid.includes - foo' in the INI file is equivalent to calling 'config.include("foo")' in the main function. And both of those are just conveniences for whatever initialization routine and arguments 'foo' requires. The nice thing about INI is it provides four things in one central place:
1. The application settings, which combine Pyramid's settings, third-party dependency configuration, and your own custom settings. 2. WSGI server settings, if using 'pserve'. 3. Logging configuration, if using 'pserve' or you call 'logging.config.FileConfig'. 4. Other sections. 'pserve' doesn't use those but your application can define its own sections if it wants to. Some people put all their includes in the INI file so that they can configure everything in one place. Others put "essential" includes and settings in their main function -- things that must be set a certain way or the application will break -- and "optional" includes and settings in the INI file -- things that can be customized by the user. However, it's sometimes difficult to make a clear distinction between the two, especially if the same include has some essential arguments and some optional ones. That leads people back to putting everything in the INI file. One disadvantage of INI is that everything comes in as strings. The Pyramid docs show routines parsing these themselves. I don't like this: it means validation bugs will happen there, perhaps deep in an obscure request. So at the beginning of my 'main' routine I call a 'process_settings' function to validate them, convert them to their proper types, and fill in default values. I tried both Formencode and Colander and ended up using Formencode, because Colander separates validation and conversion but I found too many cases where they have to be done together or I allow two types (e.g., int or None, string or None). If you don't convert the types, then any routine that uses the settings has to, incluidng dependencies, so some libraries have a second initialization function that does that (SQLAlchemy's 'engine_from_config' vs 'create_engine'). On Thu, Aug 3, 2017 at 11:08 AM, Chris Withers <ch...@withers.org> wrote: > Hi All, > > Once more determined to actually build something in pyramid, going to settle > on a REST server to feed a web front end and likely a cli tool too. > Looking for advice on best bits to use, but in the meantime, looking at: > > https://docs.pylonsproject.org/projects/pyramid_ldap/en/latest/#usage > > ...I see a bunch of config in a python file, which is what I hate most about > Django. > > I would expect to see AuthTktAuthenticationPolicy's secret and ldap queries > and password all coming from a config file. > What's the pattern for this with Pyramid? Also curious what the best way is > to structure an app beyond a trivial one-file-r like that ;-) > In my head, I'm surprised to see the configurator growing ldap_* methods (I > guess added by the config.include('pyramid_ldap')?) > > My ageing memory has something in it about .ini format files, but I know > there was some talk of making the config file format pluggable, how did that > pan out? > > Excitedly yours, > > Chris > > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pylons-discuss+unsubscr...@googlegroups.com. > To post to this group, send email to pylons-discuss@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pylons-discuss/fd1d91f4-8e6b-cf46-232d-4b9e05f0ac9f%40withers.org. > For more options, visit https://groups.google.com/d/optout. -- Mike Orr <sluggos...@gmail.com> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/CAH9f%3DuoLgva-JE03qK4TzStk1gvxfmJqub6MAx6Va8Rb3eQ9dw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.