a library for building config stores

17 views
Skip to first unread message

Chris Withers

unread,
Apr 4, 2019, 2:12:08 PM4/4/19
to pylons-...@googlegroups.com
Hey Guys,

I wanted to let Pyramid-y people know about a library I finally got
documented and released:

https://configurator.readthedocs.io/en/latest/

Partly because you're some of the best software engineers I know, and
I'd really value your feedback.

Partly because I wonder if Pyramid could make use of configurator (I
know, the name class is unfortunate...) for building the config object,
rather than being locked to .ini-ness?

Anyway, any feedback very gratefully received.

cheers,

Chris

andi

unread,
Apr 4, 2019, 11:39:46 PM4/4/19
to pylons-...@googlegroups.com
Hi Chris,

thanks a lot for your work and for sharing your library.

I'm always open to solutions that are more sophisticated than the usual ini handling as per my opinion this is too basic. Until now, I'm using ` tzf.pyramid_yml` [0][1], which has some quirks regarding the lookup of configuration files (yaml in that case), cause it is handing them either absolute or as a Python package. Other than that it works really well automatically merging a base yaml (`file_1.yaml`) and some additional "env" yaml (`file_2.yaml`) (or more than one).

I tried `configurator[yaml]` to get around the Python-package limitation of `tzf.pyramid_yml`. Loading of explicit files works well, but merging configuration of multiple files seems not as smooth as with `tzf.pyramid_yml`.

I.e. having a nested structure in `file_1.yaml` and only one override of a key in the nested structure of `file_2.yaml` will not merge and resolve properly:
```
# file_1.yaml
logging:
version: 1
disable_existing_loggers: false
root:
handlers:
- console
level: DEBUG

# file_2.yaml
logging.root.level: INFO
```

Also it would be nice to have some Pyramid specific documentation.

One thing here would be to have one snippet how to apply config values to the Pyramid `pyramid.config.Configurator`. The other interesting point is, what is possible to apply with `configurator` (I believe ` tzf.pyramid_yml` mentioned that some initial Pyramid config values are required in the ini file).

Best, Andi

[0] https://pypi.org/project/tzf.pyramid_yml/
[1] https://tzfpyramid-yml.readthedocs.io/en/v1.0.1/usage.html
--
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-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/d443543f-ef3e-c810-992e-d4bd113a32ea%40withers.org.
For more options, visit https://groups.google.com/d/optout.



Chris Withers

unread,
Apr 5, 2019, 3:07:23 AM4/5/19
to pylons-...@googlegroups.com
Hi Andi,

Firstly, thanks for the feedback!

On 05/04/2019 04:39, 'andi' via pylons-discuss wrote:
> I tried `configurator[yaml]` to get around the Python-package limitation of `tzf.pyramid_yml`. Loading of explicit files works well, but merging configuration of multiple files seems not as smooth as with `tzf.pyramid_yml`.
>
> I.e. having a nested structure in `file_1.yaml` and only one override of a key in the nested structure of `file_2.yaml` will not merge and resolve properly:
> ```
> # file_1.yaml
> logging:
> version: 1
> disable_existing_loggers: false
> root:
> handlers:
> - console
> level: DEBUG
>
> # file_2.yaml
> logging.root.level: INFO
> ```

Can you show me your example code? This works for me:

>>> from configurator import Config
>>> file_1 = Config.from_text("""
... logging:
... version: 1
... disable_existing_loggers: false
... root:
... handlers:
... - console
... level: DEBUG
... """, 'yaml')
>>> file_2 = Config.from_text('{"logging": {"root": {"level":
"INFO"}}}', 'yaml')
>>> file_1+file_2
configurator.config.Config(
{'logging': {'disable_existing_loggers': False,
'root': {'handlers': ['console'], 'level': 'INFO'},
'version': 1}}
)

> Also it would be nice to have some Pyramid specific documentation.

What would that look like? I'm not sure it belongs in the configurator
package, which is not targeting any particular framework, but I guess I
should be thinking about adding "frameworks" sections?

> One thing here would be to have one snippet how to apply config values to the Pyramid `pyramid.config.Configurator`.

If you're starting with a nested dict of config, what's he current best
practice, from Pyramid's point of view, for applying those to a
Configurator?

> The other interesting point is, what is possible to apply with `configurator` (I believe ` tzf.pyramid_yml` mentioned that some initial Pyramid config values are required in the ini file).

I'm sorry, I'm not sure what this means?

Chris

Michael Merickel

unread,
Apr 5, 2019, 4:04:14 PM4/5/19
to Pylons
Pyramid uses plaster to load files and hasn't depended on ini directly since 2017. See https://docs.pylonsproject.org/projects/pyramid/en/1.9-branch/whatsnew-1.9.html#major-feature-additions. Granted all tutorials etc still use plaster_pastedeploy as the primary connector, but anyone is free to replace it with their own binding to any format they wish.

Reply all
Reply to author
Forward
0 new messages