https://github.com/askbot/python-multi-registry
Object for aggregating key-value settings from multiple sources.
https://github.com/askbot/python-multi-registry
Last synced: 9 months ago
JSON representation
Object for aggregating key-value settings from multiple sources.
- Host: GitHub
- URL: https://github.com/askbot/python-multi-registry
- Owner: ASKBOT
- License: bsd-2-clause
- Created: 2011-08-28T15:56:31.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2011-09-10T11:27:12.000Z (over 14 years ago)
- Last Synced: 2025-04-19T20:45:42.283Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 91.8 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Allows to aggregate key-value data from many sources.
Can be used, for example, as a proxy to settings object in Django framework.
The sources of key-value data are appended to :class:`MultiRegistry`
vi ``append()`` method, then looked up via standard Python
dotted notation, as explained in more detail below.
Upon access, attributes will be looked up in the parent objects
in the order the latter were appended.
For example, if we have two settings like objects:
``A`` with attribute ``a``
and ``B`` with attribute ``b``
and we construct registry as::
from multi_registry import MultiRegistry
r = MultiRegistry()
r.append(A)
r.append(B)
then access the registry as:
``r.b`` - attrubute b will be first looked
up in the object ``A``, then in the object ``B``, where
it will be found.
If there is an attribute present in more than one appended object,
the first one will be returned - in the order of ``append()`` call.
If the attribute is not found, attribute error will be
raised.