You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
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:
ckanext-scheming version:
release-3.0.0
My team would like the
name
field to be automatically generated and match theid
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 thatcreate_validators
is not supported in a Group schema (and it is silently ignored if specified). The relevant portion of_GroupOrganizationMixin.validate()
is:ckanext-scheming/ckanext/scheming/plugins.py
Lines 180 to 183 in 8d62a28
The mixin provides support for
output_validators
, but notcreate_validators
. Compare to the implementation inSchemingDatasetsPlugin.validate()
, which has the logic required for dataset (package) schema parsing:ckanext-scheming/ckanext/scheming/plugins.py
Lines 239 to 247 in 8d62a28
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'sconvert_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:
canada_validate_generate_uuid()
validator mentioned in the CKAN GitHub discussion linked above that makes sure that the generated ID does not match any existing Group. This uses the lookup logic from the core CKANgroup_id_exists()
validator.validators:
block of our Group schema.It's not as clean as having support for
create_validators
, but it seems to be working as expected.The text was updated successfully, but these errors were encountered: