Skip to content

Commit

Permalink
#285 Improve schema extensibility - fix
Browse files Browse the repository at this point in the history
  • Loading branch information
etj committed Apr 12, 2022
1 parent fe52399 commit c8edf37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
9 changes: 5 additions & 4 deletions ckanext/dcatapit/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,12 @@ def get_icustomschema_fields():
def get_icustomschema_org_fields():
out = []
for plugin in PluginImplementations(interfaces.ICustomSchema):
extra_schema = plugin.get_custom_org_schema()
if hasattr(plugin, 'get_custom_org_schema'):
extra_schema = plugin.get_custom_org_schema()

for extra in extra_schema:
extra['external'] = True
out.extend(extra_schema)
for extra in extra_schema:
extra['external'] = True
out.extend(extra_schema)
return out


Expand Down
13 changes: 7 additions & 6 deletions ckanext/dcatapit/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,13 @@ def get_custom_package_schema():

def _update_schema_fields(package_schema: dict):
for plugin in PluginImplementations(ICustomSchema):
schema_updates = plugin.get_schema_updates()
for field in package_schema:
if field['name'] in schema_updates:
log.debug(f'Plugin {plugin} updating schema field "{field["name"]}"')
field.update(schema_updates[field['name']])
field['tainted'] = True
if hasattr(plugin, 'get_schema_updates'):
schema_updates = plugin.get_schema_updates()
for field in package_schema:
if field['name'] in schema_updates:
log.debug(f'Plugin {plugin} updating schema field "{field["name"]}"')
field.update(schema_updates[field['name']])
field['tainted'] = True


def get_custom_resource_schema():
Expand Down

0 comments on commit c8edf37

Please sign in to comment.