-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adds a predicate handler (URI handler) for slots that describe a single URI - Validates the URI per RFC-3986 - Adds an upgrade step that - Makes the new handler available - Deletes the current "Person" generator's `Photo_file_name` handler - Replaces it with a new `Photo_file_name` handler that uses the URI handler
- Loading branch information
1 parent
2c3670e
commit 748721c
Showing
8 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/edrn.rdf/edrn/rdf/profiles/default/types/edrn.rdf.uripredicatehandler.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<!-- | ||
Copyright 2024 California Institute of Technology. ALL RIGHTS | ||
RESERVED. U.S. Government Sponsorship acknowledged. | ||
--> | ||
<object name='edrn.rdf.uripredicatehandler' meta_type='Dexterity FTI' i18n:domain='edrn.rdf' | ||
xmlns:i18n='http://xml.zope.org/namespaces/i18n'> | ||
<property name='title' i18n:translate=''>URI Predicate Handler</property> | ||
<property name='description' i18n:translate=''>A handler for DMCC web services that maps a singel URI to a single RDF resource reference.</property> | ||
<property name='allow_discussion'>False</property> | ||
<property name='global_allow'>False</property> | ||
<property name='filter_content_types'>True</property> | ||
<property name='allowed_content_types' /> | ||
<property name='schema'>edrn.rdf.uripredicatehandler.IURIPredicateHandler</property> | ||
<property name='klass'>plone.dexterity.content.Item</property> | ||
<property name='add_permission'>cmf.AddPortalContent</property> | ||
<property name='behaviors'> | ||
<element value='plone.app.content.interfaces.INameFromTitle' /> | ||
</property> | ||
<property name='default_view'>view</property> | ||
<property name='default_view_fallback'>False</property> | ||
<property name='view_methods'> | ||
<element value='view' /> | ||
</property> | ||
<alias from='(Default)' to='(dynamic view)' /> | ||
<alias from='edit' to='@@edit' /> | ||
<alias from='sharing' to='@@sharing' /> | ||
<alias from='view' to='(selected layout)' /> | ||
<action title='View' action_id='view' category='object' condition_expr='' url_expr='string:${object_url}' visible='True'> | ||
<permission value='View' /> | ||
</action> | ||
<action title='Edit' action_id='edit' category='object' condition_expr='' url_expr='string:${object_url}/edit' visible='True'> | ||
<permission value='Modify portal content' /> | ||
</action> | ||
</object> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# encoding: utf-8 | ||
# Copyright 2024 California Institute of Technology. ALL RIGHTS | ||
# RESERVED. U.S. Government Sponsorship acknowledged. | ||
|
||
from .predicatehandler import ISimplePredicateHandler | ||
from Acquisition import aq_inner | ||
from rfc3986_validator import validate_rfc3986 | ||
import rdflib, logging | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class IURIPredicateHandler(ISimplePredicateHandler): | ||
'''A handler for DMCC web services that contains single URI references.''' | ||
pass | ||
|
||
|
||
class URIAsserter(object): | ||
'''Describes subjects using a predicate with a single complementary references to some other URI.''' | ||
def __init__(self, context): | ||
self.context = context | ||
|
||
def characterize(self, obj): | ||
context = aq_inner(self.context) | ||
|
||
if validate_rfc3986(obj): | ||
return [(rdflib.URIRef(context.predicateURI), rdflib.URIRef(obj))] | ||
else: | ||
_logger.warning( | ||
"Got an invalid URI «%s» for %s which won't be put into RDF", obj, self.context.title | ||
) | ||
return [] |