src/pyams_content/component/illustration/__init__.py
changeset 936 2b31cde8c028
parent 932 8e9a1496c2ba
child 971 141dc5ad83d6
equal deleted inserted replaced
930:814f7c5e04d1 936:2b31cde8c028
    13 __docformat__ = 'restructuredtext'
    13 __docformat__ = 'restructuredtext'
    14 
    14 
    15 
    15 
    16 # import standard library
    16 # import standard library
    17 
    17 
       
    18 # import packages
       
    19 from persistent import Persistent
       
    20 from pyramid.events import subscriber
       
    21 from pyramid.threadlocal import get_current_registry
       
    22 from zope.container.contained import Contained
       
    23 from zope.interface import implementer, alsoProvides
       
    24 from zope.lifecycleevent import ObjectAddedEvent
       
    25 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent
       
    26 from zope.location.interfaces import ISublocations
       
    27 from zope.schema.fieldproperty import FieldProperty
       
    28 from zope.traversing.interfaces import ITraversable
       
    29 
       
    30 from pyams_content import _
    18 # import interfaces
    31 # import interfaces
    19 from pyams_content.component.illustration.interfaces import IIllustration, IIllustrationTarget, \
    32 from pyams_content.component.illustration.interfaces import IIllustration, IIllustrationTarget, \
    20     ILLUSTRATION_KEY, ILLUSTRATION_RENDERERS, IBasicIllustration, IBasicIllustrationTarget, BASIC_ILLUSTRATION_KEY, \
    33     ILLUSTRATION_KEY, ILLUSTRATION_RENDERERS, IBasicIllustration, IBasicIllustrationTarget, BASIC_ILLUSTRATION_KEY, \
    21     ILinkIllustrationTarget, LINK_ILLUSTRATION_KEY, ILinkIllustration
    34     ILinkIllustrationTarget, LINK_ILLUSTRATION_KEY, ILinkIllustration
       
    35 from pyams_content.features.checker import BaseContentChecker
    22 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
    36 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
       
    37 from pyams_content.features.renderer import RenderedContentMixin, RenderersVocabulary
    23 from pyams_file.interfaces import IFileInfo, IImage, IResponsiveImage
    38 from pyams_file.interfaces import IFileInfo, IImage, IResponsiveImage
    24 from pyams_i18n.interfaces import INegotiator, II18n, II18nManager
    39 from pyams_i18n.interfaces import INegotiator, II18n, II18nManager
    25 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent
       
    26 from zope.location.interfaces import ISublocations
       
    27 from zope.traversing.interfaces import ITraversable
       
    28 
       
    29 # import packages
       
    30 from persistent import Persistent
       
    31 from pyams_content.features.checker import BaseContentChecker
       
    32 from pyams_content.features.renderer import RenderedContentMixin, RenderersVocabulary
       
    33 from pyams_i18n.property import I18nFileProperty
    40 from pyams_i18n.property import I18nFileProperty
    34 from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter
    41 from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter
    35 from pyams_utils.factory import factory_config
    42 from pyams_utils.factory import factory_config
    36 from pyams_utils.registry import query_utility, get_utility, get_global_registry
    43 from pyams_utils.registry import query_utility, get_utility, get_global_registry
    37 from pyams_utils.request import check_request
    44 from pyams_utils.request import check_request
    38 from pyams_utils.traversing import get_parent
    45 from pyams_utils.traversing import get_parent
    39 from pyams_utils.vocabulary import vocabulary_config
    46 from pyams_utils.vocabulary import vocabulary_config
    40 from pyramid.events import subscriber
       
    41 from pyramid.threadlocal import get_current_registry
       
    42 from zope.container.contained import Contained
       
    43 from zope.interface import implementer, alsoProvides
       
    44 from zope.lifecycleevent import ObjectCreatedEvent, ObjectAddedEvent
       
    45 from zope.schema.fieldproperty import FieldProperty
       
    46 
       
    47 from pyams_content import _
       
    48 
    47 
    49 
    48 
    50 @implementer(IBasicIllustration)
    49 @implementer(IBasicIllustration)
    51 @factory_config(provided=IBasicIllustration)
    50 @factory_config(provided=IBasicIllustration)
    52 class BasicIllustration(Persistent, Contained):
    51 class BasicIllustration(Persistent, Contained):
    53     """Illustration persistent class"""
    52     """Illustration persistent class"""
    54 
    53 
    55     _data = I18nFileProperty(IIllustration['data'])
    54     _data = I18nFileProperty(IBasicIllustration['data'])
    56     title = FieldProperty(IIllustration['title'])
    55     title = FieldProperty(IBasicIllustration['title'])
    57     alt_title = FieldProperty(IIllustration['alt_title'])
    56     alt_title = FieldProperty(IBasicIllustration['alt_title'])
       
    57     author = FieldProperty(IBasicIllustration['author'])
    58 
    58 
    59     @property
    59     @property
    60     def data(self):
    60     def data(self):
    61         return self._data
    61         return self._data
    62 
    62 
    92 @factory_config(provided=IIllustration)
    92 @factory_config(provided=IIllustration)
    93 class Illustration(RenderedContentMixin, BasicIllustration):
    93 class Illustration(RenderedContentMixin, BasicIllustration):
    94     """Illustration persistent class"""
    94     """Illustration persistent class"""
    95 
    95 
    96     description = FieldProperty(IIllustration['description'])
    96     description = FieldProperty(IIllustration['description'])
    97     author = FieldProperty(IIllustration['author'])
       
    98     renderer = FieldProperty(IIllustration['renderer'])
    97     renderer = FieldProperty(IIllustration['renderer'])
    99 
    98 
   100 
    99 
   101 @adapter_config(context=IIllustrationTarget, provides=IIllustration)
   100 @adapter_config(context=IIllustrationTarget, provides=IIllustration)
   102 def illustration_factory(context):
   101 def illustration_factory(context):