src/pyams_content/component/extfile/__init__.py
changeset 1414 3a4788a4127c
parent 1404 8be1cfb23338
equal deleted inserted replaced
1413:fbe52dda730c 1414:3a4788a4127c
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
    10 # FOR A PARTICULAR PURPOSE.
    10 # FOR A PARTICULAR PURPOSE.
    11 #
    11 #
    12 
    12 
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 import os
    13 import os
    16 
    14 
    17 from pyramid.events import subscriber
    15 from pyramid.events import subscriber
    18 from pyramid.threadlocal import get_current_registry
    16 from pyramid.threadlocal import get_current_registry
       
    17 from zope.dublincore.interfaces import IZopeDublinCore
    19 from zope.interface import alsoProvides, implementer
    18 from zope.interface import alsoProvides, implementer
    20 from zope.lifecycleevent import ObjectModifiedEvent
    19 from zope.lifecycleevent import ObjectModifiedEvent
    21 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent
    20 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, \
       
    21     IObjectRemovedEvent
    22 from zope.schema.fieldproperty import FieldProperty
    22 from zope.schema.fieldproperty import FieldProperty
    23 from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
    23 from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
    24 
    24 
    25 from pyams_content.component.association import AssociationItem
    25 from pyams_content.component.association import AssociationItem
    26 from pyams_content.component.association.interfaces import IAssociationInfo
    26 from pyams_content.component.association.interfaces import IAssociationInfo
    27 from pyams_content.component.extfile.interfaces import IBaseExtFile, IExtAudio, IExtFile, IExtFileManagerInfo, \
    27 from pyams_content.component.extfile.interfaces import IBaseExtFile, IExtAudio, IExtFile, \
    28     IExtImage, IExtMedia, IExtVideo
    28     IExtFileManagerInfo, IExtImage, IExtMedia, IExtVideo
    29 from pyams_content.features.checker import BaseContentChecker
    29 from pyams_content.features.checker import BaseContentChecker
    30 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_LANG_VALUE, MISSING_VALUE
    30 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_LANG_VALUE, \
       
    31     MISSING_VALUE
    31 from pyams_content.shared.common.interfaces import IWfSharedContent
    32 from pyams_content.shared.common.interfaces import IWfSharedContent
    32 from pyams_file.file import EXTENSIONS_THUMBNAILS
    33 from pyams_file.file import EXTENSIONS_THUMBNAILS
    33 from pyams_file.interfaces import IFileInfo, IImage, IResponsiveImage
    34 from pyams_file.interfaces import IFileInfo, IImage, IResponsiveImage
    34 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
    35 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
    35 from pyams_i18n.property import I18nFileProperty
    36 from pyams_i18n.property import I18nFileProperty
    38 from pyams_utils.request import check_request
    39 from pyams_utils.request import check_request
    39 from pyams_utils.size import get_human_size
    40 from pyams_utils.size import get_human_size
    40 from pyams_utils.traversing import get_parent
    41 from pyams_utils.traversing import get_parent
    41 from pyams_utils.vocabulary import vocabulary_config
    42 from pyams_utils.vocabulary import vocabulary_config
    42 
    43 
       
    44 
       
    45 __docformat__ = 'restructuredtext'
       
    46 
    43 from pyams_content import _
    47 from pyams_content import _
    44 
    48 
    45 
    49 
    46 EXTERNAL_FILES_FACTORIES = {}
    50 EXTERNAL_FILES_FACTORIES = {}
    47 
    51 
    88         title = II18n(self.context).query_attribute('title')
    92         title = II18n(self.context).query_attribute('title')
    89         if not title:
    93         if not title:
    90             title = self.context.filename
    94             title = self.context.filename
    91             if '.' in title:
    95             if '.' in title:
    92                 title, extension = title.rsplit('.', 1)
    96                 title, extension = title.rsplit('.', 1)
    93         return '{0} {1}'.format(II18n(manager_info).query_attribute('default_title_prefix', request=request) or '',
    97         return '{0} {1}'.format(II18n(manager_info).query_attribute('default_title_prefix',
       
    98                                                                     request=request) or '',
    94                                 title)
    99                                 title)
    95 
   100 
    96     @property
   101     @property
    97     def user_icon(self):
   102     def user_icon(self):
    98         filename = self.context.filename
   103         filename = self.context.filename