Added content link relative URL adapter
authorThierry Florac <thierry.florac@onf.fr>
Wed, 27 Jun 2018 15:31:57 +0200
changeset 760 ff178ccbce6f
parent 759 780d6776a857
child 761 ea8f9d40935e
Added content link relative URL adapter
src/pyams_content/shared/site/link.py
--- a/src/pyams_content/shared/site/link.py	Wed Jun 27 15:15:38 2018 +0200
+++ b/src/pyams_content/shared/site/link.py	Wed Jun 27 15:31:57 2018 +0200
@@ -9,6 +9,8 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyams_skin.layer import IPyAMSUserLayer
+from pyams_utils.interfaces.url import IRelativeURL
 
 __docformat__ = 'restructuredtext'
 
@@ -83,3 +85,11 @@
     target = context.get_target()
     if target is not None:
         return IWorkflowPublicationInfo(target, None)
+
+
+@adapter_config(context=(IContentLink, IPyAMSUserLayer), provides=IRelativeURL)
+def content_link_relative_url(context):
+    """Content link relative URL"""
+    target = context.get_target()
+    if target is not None:
+        return IRelativeURL(target, None)