Skip to content

Config providers #1

Closed
Closed
@rmk135

Description

@rmk135

There are some kind of situations with settings injections that should be handled in special way:

- Most of the systems make settings global usable (Django settings, Flask app.config etc...). This is not a best practice.
- Settings could be defined after the objects catalog is defined. So best what `objects` can do now is:
class Catalog(AbstractCatalog):

    config = ExternalDependency(instance_of=dict)

    consumer = NewInstance(SomeClass,
                           InitArg('config', config))


Catalog.config.satisfy(Object(dict(some_key='some_value')))

The idea is to make special type of provider for such cases:

class Catalog(AbstractCatalog):

    config = Config()

    consumer = NewInstance(SomeClass,
                           InitArg('some_setting', config.some_key))


Catalog.config.satisfy(Object(dict(some_key='some_value')))

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions