Merge lp:~ricardokirkner/configglue/declarative-syntax into lp:configglue
Status: | Merged |
---|---|
Approved by: | Ricardo Kirkner |
Approved revision: | 46 |
Merged at revision: | 39 |
Proposed branch: | lp:~ricardokirkner/configglue/declarative-syntax |
Merge into: | lp:configglue |
Diff against target: |
145 lines (+43/-34) 2 files modified
configglue/pyschema/schema.py (+13/-34) tests/pyschema/test_schema.py (+30/-0) |
To merge this branch: | bzr merge lp:~ricardokirkner/configglue/declarative-syntax |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John Lenton | Approve | ||
Review via email: mp+55003@code.launchpad.net |
Commit message
fixes proper schema inheritance using declarative syntax
Description of the change
This branch fixes proper schema inheritance using declarative syntax.
For example:
class SchemaA(Schema):
foo = ConfigSection()
foo.bar = IntConfigOption()
class SchemaB(SchemaA):
foo = deepcopy(
foo.baz = BoolConfigOption()
In this code, the SchemaB class would have a section called 'foo' with *two* options, 'bar' and 'baz'. When initializing the class instance, all attributes get merged so that they get correctly overridden by the subclass' attributes.
It's necessary to have the section duplicate, as not having it results in a syntax error. By merging sections together at initialization, the end effect is the desired one, however.
Wouldn't it be easier to just merge resulting _sections dictionaries instead of digging out all the information from classes?
Something like:
- run superclass's configuration definition code, which creates internal structures (_sections?),
- run current class configuration definition code but save it to different structure,
- merge resulting structures.
This should be simpler and require less usage of __class__ and __mro__ attributes.