src/pyams_content/component/paragraph/frame.py
changeset 1398 fc32ec8a8f53
parent 1157 ffb751b038cc
equal deleted inserted replaced
1397:d05fc6aa4217 1398:fc32ec8a8f53
    10 # FOR A PARTICULAR PURPOSE.
    10 # FOR A PARTICULAR PURPOSE.
    11 #
    11 #
    12 
    12 
    13 __docformat__ = 'restructuredtext'
    13 __docformat__ = 'restructuredtext'
    14 
    14 
       
    15 from pyramid.events import subscriber
    15 from zope.interface import implementer
    16 from zope.interface import implementer
       
    17 from zope.lifecycleevent import IObjectAddedEvent, IObjectModifiedEvent
    16 from zope.schema.fieldproperty import FieldProperty
    18 from zope.schema.fieldproperty import FieldProperty
    17 
    19 
    18 from pyams_content.component.extfile.interfaces import IExtFileContainerTarget
    20 from pyams_content.component.extfile.interfaces import IExtFileContainerTarget
    19 from pyams_content.component.illustration.interfaces import IIllustrationTarget
    21 from pyams_content.component.illustration.interfaces import IIllustrationTarget
    20 from pyams_content.component.links.interfaces import ILinkContainerTarget
    22 from pyams_content.component.links.interfaces import ILinkContainerTarget
    21 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory
    23 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, \
       
    24     BaseParagraphFactory
       
    25 from pyams_content.component.paragraph.association import check_associations
    22 from pyams_content.component.paragraph.interfaces import IParagraphFactory
    26 from pyams_content.component.paragraph.interfaces import IParagraphFactory
    23 from pyams_content.component.paragraph.interfaces.frame import FRAME_PARAGRAPH_NAME, FRAME_PARAGRAPH_RENDERERS, \
    27 from pyams_content.component.paragraph.interfaces.frame import FRAME_PARAGRAPH_NAME, \
    24     FRAME_PARAGRAPH_TYPE, IFrameParagraph
    28     FRAME_PARAGRAPH_RENDERERS, FRAME_PARAGRAPH_TYPE, IFrameParagraph
    25 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_LANG_VALUE, MISSING_VALUE
    29 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_LANG_VALUE, \
       
    30     MISSING_VALUE
    26 from pyams_content.features.renderer import RenderersVocabulary
    31 from pyams_content.features.renderer import RenderersVocabulary
    27 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
    32 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
    28 from pyams_utils.adapter import adapter_config
    33 from pyams_utils.adapter import adapter_config
    29 from pyams_utils.factory import factory_config
    34 from pyams_utils.factory import factory_config
    30 from pyams_utils.registry import get_utility, utility_config
    35 from pyams_utils.registry import get_utility, utility_config
    86 @vocabulary_config(name=FRAME_PARAGRAPH_RENDERERS)
    91 @vocabulary_config(name=FRAME_PARAGRAPH_RENDERERS)
    87 class FrameParagraphRendererVocabulary(RenderersVocabulary):
    92 class FrameParagraphRendererVocabulary(RenderersVocabulary):
    88     """Framed text paragraph renderers vocabulary"""
    93     """Framed text paragraph renderers vocabulary"""
    89 
    94 
    90     content_interface = IFrameParagraph
    95     content_interface = IFrameParagraph
       
    96 
       
    97 
       
    98 @subscriber(IObjectAddedEvent, context_selector=IFrameParagraph)
       
    99 def handle_added_frame_paragraph(event):
       
   100     """Check for new associations from added paragraph"""
       
   101     paragraph = event.object
       
   102     for lang, body in (paragraph.body or {}).items():
       
   103         check_associations(paragraph, body, lang, notify=False)
       
   104 
       
   105 
       
   106 @subscriber(IObjectModifiedEvent, context_selector=IFrameParagraph)
       
   107 def handle_modified_frame_paragraph(event):
       
   108     """Check for new associations from modified paragraph"""
       
   109     paragraph = event.object
       
   110     for lang, body in (paragraph.body or {}).items():
       
   111         check_associations(paragraph, body, lang, notify=False)
       
   112