# HG changeset patch # User Thierry Florac # Date 1543221130 -3600 # Node ID f286ddfd87ec1ea9b73cc216af565bfd7e033083 # Parent 6ca2680774ee379e56b31f1e5950461f483e91cb Added "get_dynamic_link" function to create an internal link dynamically from an internal reference diff -r 6ca2680774ee -r f286ddfd87ec src/pyams_content/component/links/__init__.py --- a/src/pyams_content/component/links/__init__.py Mon Nov 26 09:30:37 2018 +0100 +++ b/src/pyams_content/component/links/__init__.py Mon Nov 26 09:32:10 2018 +0100 @@ -12,36 +12,31 @@ __docformat__ = 'restructuredtext' - -# import standard library +from zope.interface import implementer +from zope.schema.fieldproperty import FieldProperty +from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary -# import interfaces -from pyams_content.component.association.interfaces import IAssociationInfo, IAssociationContainerTarget, \ - IAssociationContainer -from pyams_content.component.links.interfaces import IBaseLink, IInternalLink, IExternalLink, IMailtoLink -from pyams_content.features.checker.interfaces import IContentChecker, ERROR_VALUE +from pyams_content.component.association import AssociationItem +from pyams_content.component.association.interfaces import IAssociationContainer, IAssociationContainerTarget, \ + IAssociationInfo +from pyams_content.component.links.interfaces import IBaseLink, IExternalLink, IInternalLink, IMailtoLink +from pyams_content.features.checker import BaseContentChecker +from pyams_content.features.checker.interfaces import ERROR_VALUE, IContentChecker from pyams_content.interfaces import IBaseContent, MANAGE_CONTENT_PERMISSION from pyams_content.reference.pictograms.interfaces import IPictogramTable from pyams_form.interfaces.form import IFormContextPermissionChecker from pyams_i18n.interfaces import II18n -from pyams_sequence.interfaces import ISequentialIdInfo, IInternalReference +from pyams_sequence.interfaces import IInternalReference, ISequentialIdInfo +from pyams_sequence.reference import get_reference_target from pyams_skin.layer import IPyAMSUserLayer -from pyams_workflow.interfaces import IWorkflow, IWorkflowPublicationInfo - -# import packages -from pyams_content.component.association import AssociationItem -from pyams_content.features.checker import BaseContentChecker -from pyams_sequence.reference import get_reference_target -from pyams_utils.adapter import adapter_config, ContextAdapter +from pyams_utils.adapter import ContextAdapter, adapter_config from pyams_utils.registry import query_utility from pyams_utils.request import check_request from pyams_utils.traversing import get_parent from pyams_utils.url import relative_url from pyams_utils.vocabulary import vocabulary_config from pyams_utils.zodb import volatile_property -from zope.interface import implementer -from zope.schema.fieldproperty import FieldProperty -from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm +from pyams_workflow.interfaces import IWorkflow, IWorkflowPublicationInfo from pyams_content import _ @@ -218,6 +213,13 @@ return output +def get_dynamic_link(target): + """Create dynamic internal link object from target""" + result = InternalLink() + result.reference = ISequentialIdInfo(target).hex_oid + return result + + # # External links #