pyventory icon indicating copy to clipboard operation
pyventory copied to clipboard

Allow to override parts of the complex structures

Open lig opened this issue 8 years ago • 1 comments

Allow overriding parts of the structures defined using complex dicts structures like the following

class MyAsset(Asset):
    complex_var = dict(
        key1=dict(
            sub_key1='sub_value1',
            sub_key2='sub_value2',
        )
        key2='value2',
    )

lig avatar Mar 07 '17 15:03 lig

Well, it looks like in most cases this could be achieved by creation of a mixin that handles variables extracted from the original asset. Consider the following example.

class OriginalAsset(Asset):
    foo = dict(
        key1='value1',
        key2='value2',
    )

This could be represented in the following way

class Key1Mixin:
    foo_key1 = 'value1'

class OriginalAsset(Key1Mixin, Asset):
    foo = dict(
        key2='value2',
    )

or just

class OriginalAsset(Asset):
    foo = dict(
        key2='value2',
    )
    foo_key1 = 'value1'

I'm going to concentrate on the other features for now. Let's look how Scopes feature implementation will affect this.

lig avatar Mar 11 '17 23:03 lig