src/pyams_content/component/paragraph/video.py
changeset 584 bfc376efd87c
parent 569 9a5f52b5d876
child 585 9fa8e9776bda
equal deleted inserted replaced
583:a3df1b69616b 584:bfc376efd87c
    19 from pyams_content.component.paragraph.interfaces import IParagraphFactory
    19 from pyams_content.component.paragraph.interfaces import IParagraphFactory
    20 from pyams_content.component.paragraph.interfaces.video import IVideoParagraph, VIDEO_PARAGRAPH_TYPE, \
    20 from pyams_content.component.paragraph.interfaces.video import IVideoParagraph, VIDEO_PARAGRAPH_TYPE, \
    21     VIDEO_PARAGRAPH_RENDERERS
    21     VIDEO_PARAGRAPH_RENDERERS
    22 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
    22 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
    23 from pyams_i18n.interfaces import II18nManager, INegotiator, II18n
    23 from pyams_i18n.interfaces import II18nManager, INegotiator, II18n
    24 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent
       
    25 
    24 
    26 # import packages
    25 # import packages
    27 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory
    26 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory
    28 from pyams_content.component.paragraph.html import check_associations
       
    29 from pyams_content.features.renderer import RenderersVocabulary
    27 from pyams_content.features.renderer import RenderersVocabulary
    30 from pyams_file.property import FileProperty
    28 from pyams_file.property import FileProperty
    31 from pyams_utils.adapter import adapter_config
    29 from pyams_utils.adapter import adapter_config
    32 from pyams_utils.factory import factory_config
    30 from pyams_utils.factory import factory_config
    33 from pyams_utils.registry import utility_config, get_utility
    31 from pyams_utils.registry import utility_config, get_utility
    34 from pyams_utils.traversing import get_parent
    32 from pyams_utils.traversing import get_parent
    35 from pyams_utils.vocabulary import vocabulary_config
    33 from pyams_utils.vocabulary import vocabulary_config
    36 from pyramid.events import subscriber
       
    37 from zope.interface import implementer
    34 from zope.interface import implementer
    38 from zope.schema.fieldproperty import FieldProperty
    35 from zope.schema.fieldproperty import FieldProperty
    39 
    36 
    40 from pyams_content import _
    37 from pyams_content import _
    41 
    38 
    59 class VideoParagraphFactory(BaseParagraphFactory):
    56 class VideoParagraphFactory(BaseParagraphFactory):
    60     """Video paragraph factory"""
    57     """Video paragraph factory"""
    61 
    58 
    62     name = _("Video")
    59     name = _("Video")
    63     content_type = VideoParagraph
    60     content_type = VideoParagraph
    64 
       
    65 
       
    66 @subscriber(IObjectAddedEvent, context_selector=IVideoParagraph)
       
    67 def handle_added_video_paragraph(event):
       
    68     """Check for new associations from added paragraph"""
       
    69     paragraph = event.object
       
    70     for lang, body in (paragraph.body or {}).items():
       
    71         check_associations(paragraph, body, lang, notify=False)
       
    72 
       
    73 
       
    74 @subscriber(IObjectModifiedEvent, context_selector=IVideoParagraph)
       
    75 def handle_modified_video_paragraph(event):
       
    76     """Check for new associations from modified paragraph"""
       
    77     paragraph = event.object
       
    78     for lang, body in (paragraph.body or {}).items():
       
    79         check_associations(paragraph, body, lang, notify=False)
       
    80 
    61 
    81 
    62 
    82 @adapter_config(context=IVideoParagraph, provides=IContentChecker)
    63 @adapter_config(context=IVideoParagraph, provides=IContentChecker)
    83 class VideoParagraphContentChecker(BaseParagraphContentChecker):
    64 class VideoParagraphContentChecker(BaseParagraphContentChecker):
    84     """Video paragraph content checker"""
    65     """Video paragraph content checker"""