Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering elements from lists of dicts like 'cited-responsible-party' #7

Open
aianta opened this issue Jul 5, 2021 · 2 comments
Open

Comments

@aianta
Copy link
Collaborator

aianta commented Jul 5, 2021

Certain fields in pkg_dict contain lists of objects. One such example is cited-responsible-party.

u 'cited-responsible-party': [{
            u 'contact-info_email': u '',
            u 'contact-info_online-resource_application-profile': u '',
            u 'contact-info_online-resource_description': u '',
            u 'contact-info_online-resource_function': u '',
            u 'contact-info_online-resource_name': u '',
            u 'contact-info_online-resource_protocol': u '',
            u 'contact-info_online-resource_protocol-request': u '',
            u 'contact-info_online-resource_url': u 'https://www.mi.mun.ca/departments/centreforappliedoceantechnology/',
            u 'individual-name': u 'Marine Institute',
            u 'organisation-name': u '',
            u 'position-name': u '',
            u 'role': u 'author'
        }
    ]

For the time being the plugin doesn't support filtering on these fields as there is no straight forward way to generalize filtering logic. Objects within a list are not guaranteed to have the same fields meaning that filtering would always have to be decided on a per package basis.

Until such time that this functionality is requested by a stakeholder this issue can be placed on the back burner.

@greebie
Copy link
Contributor

greebie commented Jul 5, 2021

Agreed. I think a possible solution (if requested or partially requested) is to create model objects by inheriting dict into a class. https://stackoverflow.com/questions/61517/python-dictionary-from-an-objects-fields

If we want even more control, I think it's also possible to create immutable objects by extending Tuple or named tuple (using the associated library). https://stackoverflow.com/questions/51342228/python-equivalent-of-scala-case-class

Python 3.7 has the data class object, which is a nice feature to have down the road.

@greebie
Copy link
Contributor

greebie commented Jul 8, 2021

Based on discussion, we felt that our efforts could benefit from a data model that was implemented across the ckan extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants