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

Groups/Organizations silently ignore create_validators #404

Open
themowski opened this issue Mar 8, 2024 · 0 comments
Open

Groups/Organizations silently ignore create_validators #404

themowski opened this issue Mar 8, 2024 · 0 comments

Comments

@themowski
Copy link
Contributor

ckanext-scheming version: release-3.0.0

My team would like the name field to be automatically generated and match the id field for our CKAN Groups. We previously got this working for Datasets using the guidance that was posted in response to our CKAN discussion forum post.

I tried implementing the same approach for Groups, but it did not work [1]. I looked at the ckanext-scheming code and discovered that create_validators is not supported in a Group schema (and it is silently ignored if specified). The relevant portion of _GroupOrganizationMixin.validate() is:

get_validators = (
_field_output_validators_group
if action_type == 'show' else _field_validators
)

The mixin provides support for output_validators, but not create_validators. Compare to the implementation in SchemingDatasetsPlugin.validate(), which has the logic required for dataset (package) schema parsing:

before = scheming_schema.get('before_validators')
after = scheming_schema.get('after_validators')
if action_type == 'show':
get_validators = _field_output_validators
before = after = None
elif action_type == 'create':
get_validators = _field_create_validators
else:
get_validators = _field_validators

It looks like patching this in is non-trivial... as shown in the code snippets above, in the Group/Org case, there is a separate function called _field_output_validators_group() that wraps _field_output_validators() (used in the Dataset/Package case) and specifies the value of the latter's convert_from_extras_type argument. This input argument is not part of the signature of _field_create_validators(), and it's not clear to me if it needs to be.


[1] On an unrelated note, my team ended up accomplishing what we needed by:

It's not as clean as having support for create_validators, but it seems to be working as expected.

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

1 participant