src/pyams_content/shared/common/__init__.py
changeset 277 9649f8ce3b1c
parent 273 d70e47b99ffb
child 305 b5967aacf4c1
equal deleted inserted replaced
276:78422a1c4228 277:9649f8ce3b1c
    18 # import interfaces
    18 # import interfaces
    19 from hypatia.interfaces import ICatalog
    19 from hypatia.interfaces import ICatalog
    20 from pyams_content.interfaces import IBaseContentInfo
    20 from pyams_content.interfaces import IBaseContentInfo
    21 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
    21 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
    22 from pyams_content.features.review.interfaces import IReviewComments
    22 from pyams_content.features.review.interfaces import IReviewComments
    23 from pyams_content.shared.common.interfaces import IWfSharedContent, IWfSharedContentRoles, ISharedContent, ISharedTool
    23 from pyams_content.shared.common.interfaces import IWfSharedContent, IWfSharedContentRoles, ISharedContent, \
       
    24     IBaseSharedTool, ISharedSite
    24 from pyams_i18n.interfaces import II18nManager, II18n
    25 from pyams_i18n.interfaces import II18nManager, II18n
    25 from pyams_security.interfaces import IDefaultProtectionPolicy
    26 from pyams_security.interfaces import IDefaultProtectionPolicy
    26 from pyams_sequence.interfaces import ISequentialIdTarget, ISequentialIdInfo
    27 from pyams_sequence.interfaces import ISequentialIdTarget, ISequentialIdInfo
    27 from pyams_utils.interfaces import VIEW_PERMISSION
    28 from pyams_utils.interfaces import VIEW_PERMISSION
    28 from pyams_workflow.interfaces import IWorkflowPublicationSupport, IWorkflow, IObjectClonedEvent, IWorkflowVersions
    29 from pyams_workflow.interfaces import IWorkflowPublicationSupport, IWorkflow, IObjectClonedEvent, IWorkflowVersions
    38 from pyams_security.property import RolePrincipalsFieldProperty
    39 from pyams_security.property import RolePrincipalsFieldProperty
    39 from pyams_security.security import ProtectedObject
    40 from pyams_security.security import ProtectedObject
    40 from pyams_security.utility import get_principal
    41 from pyams_security.utility import get_principal
    41 from pyams_utils.adapter import adapter_config, ContextAdapter
    42 from pyams_utils.adapter import adapter_config, ContextAdapter
    42 from pyams_utils.date import format_datetime
    43 from pyams_utils.date import format_datetime
    43 from pyams_utils.registry import query_utility
    44 from pyams_utils.registry import query_utility, get_utilities_for
    44 from pyams_utils.request import query_request, check_request
    45 from pyams_utils.request import query_request, check_request
    45 from pyams_utils.timezone import tztime
    46 from pyams_utils.timezone import tztime
    46 from pyams_utils.traversing import get_parent
    47 from pyams_utils.traversing import get_parent
    47 from pyams_utils.vocabulary import vocabulary_config
    48 from pyams_utils.vocabulary import vocabulary_config
    48 from pyramid.events import subscriber
    49 from pyramid.events import subscriber
    52 from zope.interface import implementer
    53 from zope.interface import implementer
    53 from zope.schema.fieldproperty import FieldProperty
    54 from zope.schema.fieldproperty import FieldProperty
    54 from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
    55 from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
    55 
    56 
    56 from pyams_content import _
    57 from pyams_content import _
       
    58 
       
    59 
       
    60 @vocabulary_config(name='PyAMS shared sites')
       
    61 class SharedSiteVocabulary(SimpleVocabulary):
       
    62     """Shared sites vocabulary"""
       
    63 
       
    64     interface = ISharedSite
       
    65 
       
    66     def __init__(self, context):
       
    67         request = query_request()
       
    68         super(SharedSiteVocabulary, self).__init__([SimpleTerm(v, title=II18n(t).query_attribute('title',
       
    69                                                                                                  request=request))
       
    70                                                     for v, t in get_utilities_for(self.interface)])
    57 
    71 
    58 
    72 
    59 #
    73 #
    60 # Content types management
    74 # Content types management
    61 #
    75 #
   203 
   217 
   204 
   218 
   205 @adapter_config(context=IWfSharedContent, provides=IWorkflow)
   219 @adapter_config(context=IWfSharedContent, provides=IWorkflow)
   206 def WfSharedContentWorkflowAdapter(context):
   220 def WfSharedContentWorkflowAdapter(context):
   207     """Shared content workflow adapter"""
   221     """Shared content workflow adapter"""
   208     parent = get_parent(context, ISharedTool)
   222     parent = get_parent(context, IBaseSharedTool)
   209     return query_utility(IWorkflow, name=parent.shared_content_workflow)
   223     return query_utility(IWorkflow, name=parent.shared_content_workflow)
   210 
   224 
   211 
   225 
   212 @adapter_config(name='properties', context=IWfSharedContent, provides=IContentChecker)
   226 @adapter_config(name='properties', context=IWfSharedContent, provides=IContentChecker)
   213 class WfSharedContentChecker(BaseContentChecker):
   227 class WfSharedContentChecker(BaseContentChecker):
   249     sequence_name = ''  # use default sequence generator
   263     sequence_name = ''  # use default sequence generator
   250     sequence_prefix = ''
   264     sequence_prefix = ''
   251 
   265 
   252     @property
   266     @property
   253     def workflow_name(self):
   267     def workflow_name(self):
   254         return get_parent(self, ISharedTool).shared_content_workflow
   268         return get_parent(self, IBaseSharedTool).shared_content_workflow
   255 
   269 
   256 
   270 
   257 @adapter_config(context=ISharedContent, provides=IBaseContentInfo)
   271 @adapter_config(context=ISharedContent, provides=IBaseContentInfo)
   258 class SharedContentInfoAdapter(ContextAdapter):
   272 class SharedContentInfoAdapter(ContextAdapter):
   259     """Shared content base info adapter"""
   273     """Shared content base info adapter"""
   268 
   282 
   269 
   283 
   270 @adapter_config(context=ISharedContent, provides=IWorkflow)
   284 @adapter_config(context=ISharedContent, provides=IWorkflow)
   271 def SharedContentWorkflowAdapter(context):
   285 def SharedContentWorkflowAdapter(context):
   272     """Shared content workflow adapter"""
   286     """Shared content workflow adapter"""
   273     parent = get_parent(context, ISharedTool)
   287     parent = get_parent(context, IBaseSharedTool)
   274     return query_utility(IWorkflow, name=parent.shared_content_workflow)
   288     return query_utility(IWorkflow, name=parent.shared_content_workflow)