--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/common/skin/__init__.py Fri Jun 22 13:03:11 2018 +0200
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+
+# import packages
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/common/skin/oid.py Fri Jun 22 13:03:11 2018 +0200
@@ -0,0 +1,56 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_sequence.interfaces import ISequentialIntIds
+from pyams_skin.layer import IPyAMSUserLayer
+from pyams_utils.interfaces.url import DISPLAY_CONTEXT
+from pyams_workflow.interfaces import IWorkflow, IWorkflowVersions
+from zope.traversing.interfaces import ITraversable
+
+# import packages
+from pyams_sequence.utility import get_reference_target
+from pyams_utils.adapter import adapter_config, ContextRequestAdapter
+from pyams_utils.registry import get_utility
+from pyramid.exceptions import NotFound
+from zope.interface import Interface
+
+
+@adapter_config(name='oid', context=(Interface, IPyAMSUserLayer), provides=ITraversable)
+class OidTraverser(ContextRequestAdapter):
+ """++oid++ traverser"""
+
+ def traverse(self, name, furtherpath=None):
+ if not name:
+ raise NotFound()
+ if '::' in name:
+ oid, label = name.split('::', 1)
+ else:
+ oid = name
+ sequence = get_utility(ISequentialIntIds)
+ reference = sequence.get_full_oid(oid)
+ target = get_reference_target(reference)
+ if target is not None:
+ workflow = IWorkflow(target, None)
+ if workflow is not None:
+ versions = IWorkflowVersions(target).get_versions(workflow.published_states, sort=True)
+ if versions:
+ target = versions[-1]
+ if target is not None:
+ self.request.annotations[DISPLAY_CONTEXT] = self.context
+ return target
+ raise NotFound()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/common/skin/url.py Fri Jun 22 13:03:11 2018 +0200
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_content.shared.common import IWfSharedContent
+from pyams_sequence.interfaces import ISequentialIdInfo
+from pyams_skin.layer import IPyAMSUserLayer
+from pyams_utils.interfaces.url import IRelativeURL
+
+# import packages
+from pyams_utils.adapter import adapter_config, ContextRequestAdapter
+from pyams_utils.url import absolute_url
+
+
+@adapter_config(context=(IWfSharedContent, IPyAMSUserLayer), provides=IRelativeURL)
+class SharedContentRelativeUrlAdapter(ContextRequestAdapter):
+ """Shared content relative URL adapter"""
+
+ def get_url(self, display_context=None, view_name=None, query=None):
+ return absolute_url(display_context, self.request,
+ '++oid++{0}::{1}.html'.format(
+ ISequentialIdInfo(self.context).get_base_oid().strip(),
+ self.context.content_url))