Back to index

plone3  3.1.7
setuphandlers.py
Go to the documentation of this file.
00001 """
00002 CMFEditions setup handlers.
00003 """
00004 
00005 from Acquisition import aq_base
00006 from Products.CMFCore.utils import getToolByName
00007 from Products.CMFEditions import StandardModifiers
00008 from Products.CMFEditions.VersionPolicies import ATVersionOnEditPolicy
00009 
00010 # File and image versioning are disabled by default until we have modifiers to
00011 # handle their primary fields efficiently
00012 VERSIONING_ACTIONS = {'Document':'version_document_view',
00013                       #'File':'version_file_view',
00014                       #'Image':'version_image_view',
00015                       'News Item':'version_news_item_view',
00016                       'ATDocument':'version_atdocument_view',
00017                       'Event': '',
00018                       'Link': '',
00019                       #'ATFile':'version_atfile_view',
00020                       #'ATImage':'version_atimage_view',
00021                       'ATNewsItem':'version_atnews_item_view',}
00022 
00023 ADD_POLICIES = (('at_edit_autoversion',
00024                     'Create version on edit (AT objects only)',
00025                      ATVersionOnEditPolicy),
00026                  ('version_on_revert',
00027                     'Create version on version revert'),
00028                )
00029 
00030 DEFAULT_POLICIES = ('at_edit_autoversion', 'version_on_revert')
00031 
00032 def importVarious(context):
00033     """
00034     Import various settings.
00035 
00036     Provisional handler that does initialization that is not yet taken
00037     care of by other handlers.
00038     """
00039     # Only run step if a flag file is present
00040     if context.readDataFile('cmfeditions_various.txt') is None:
00041         return
00042     site = context.getSite()
00043     portal_modifier = getToolByName(site, 'portal_modifier')
00044     StandardModifiers.install(portal_modifier)
00045     portal_repository = getToolByName(site, 'portal_repository')
00046     portal_repository.setAutoApplyMode(True)
00047     portal_repository.setVersionableContentTypes(VERSIONING_ACTIONS.keys())
00048     portal_repository._migrateVersionPolicies()
00049     portal_repository.manage_changePolicyDefs(ADD_POLICIES)
00050     for ctype in VERSIONING_ACTIONS:
00051         for policy_id in DEFAULT_POLICIES:
00052             portal_repository.addPolicyForContentType(ctype, policy_id)