Added "+" ITraversable adapter to support direct content access as defined in PyAMS_utils namespace traverser
authorThierry Florac <tflorac@ulthar.net>
Wed, 09 Jan 2019 10:18:00 +0100
changeset 354 5ca9b0d569a5
parent 353 1ed87336d991
child 355 a9ecbf6ad7ed
Added "+" ITraversable adapter to support direct content access as defined in PyAMS_utils namespace traverser
src/pyams_default_theme/shared/common/oid.py
--- a/src/pyams_default_theme/shared/common/oid.py	Wed Jan 09 10:16:22 2019 +0100
+++ b/src/pyams_default_theme/shared/common/oid.py	Wed Jan 09 10:18:00 2019 +0100
@@ -25,17 +25,22 @@
 from pyams_workflow.interfaces import IWorkflow, IWorkflowPublicationInfo, IWorkflowVersions
 
 
+@adapter_config(name='+', context=(Interface, IPyAMSUserLayer), provides=ITraversable)
 @adapter_config(name='oid', context=(Interface, IPyAMSUserLayer), provides=ITraversable)
 class OidTraverser(ContextRequestAdapter):
-    """++oid++ traverser"""
+    """++oid++ traverser
+
+    This traverser can be used to get a direct access to any content having an OID.
+    The general URL syntax is "*/++oid++{oid}::{title}.html", where {oid} is the internal OID of the
+    requested content, dans "title" it's "content URL" attribute.
+
+    A shorter syntax, is now available: */+/{oid}::{title}.html
+    """
 
     def traverse(self, name, furtherpath=None):
         if not name:
             raise NotFound()
-        if '::' in name:
-            oid, label = name.split('::', 1)
-        else:
-            oid = name
+        oid = name.split('::')[0]
         sequence = get_utility(ISequentialIntIds)
         reference = sequence.get_full_oid(oid)
         target = get_reference_target(reference)