Back to index

plone3  3.1.7
__init__.py
Go to the documentation of this file.
00001 import sys
00002 import os
00003 import Globals
00004 
00005 cmfplone_globals = globals()
00006 this_module = sys.modules[ __name__ ]
00007 _marker = []
00008 
00009 ADD_CONTENT_PERMISSION = 'Add portal content'
00010 
00011 misc_ = {'plone_icon': Globals.ImageFile(
00012                        os.path.join('skins', 'plone_images', 'logoIcon.gif'),
00013                        cmfplone_globals)}
00014 
00015 
00016 def initialize(context):
00017 
00018     # Stuff has been moved from module level to this method for a
00019     # better separation of import and installation.
00020     # For the general user this change does not make a difference.
00021     # For test authors (and people who use parts of Plone only)
00022     # it does speed up import *significantly*.
00023 
00024     from AccessControl import ModuleSecurityInfo
00025     from AccessControl import allow_module, allow_class
00026 
00027     # allow logging
00028     ModuleSecurityInfo('logging').declarePublic('getLogger')
00029     from logging import Logger
00030     allow_class(Logger)
00031 
00032     # Register kss extension to allow it used from fs skins
00033     from Products.CMFCore.DirectoryView import registerFileExtension
00034     from Products.CMFCore.FSFile import FSFile
00035     registerFileExtension('kss', FSFile)
00036 
00037     # various small utils functions
00038     # added for unescaping view names in urls when finding selected action
00039     ModuleSecurityInfo('urllib').declarePublic('unquote')
00040     
00041     allow_module('Products.CMFPlone.utils')
00042 
00043     # For form validation bits
00044     from Products.CMFPlone.utils import IndexIterator
00045     allow_class(IndexIterator)
00046 
00047     # Make IndexIterator available at module level
00048     this_module.IndexIterator = IndexIterator
00049 
00050     # For content_status_modify
00051     from Products.CMFCore.WorkflowCore import ObjectMoved, ObjectDeleted, \
00052                                               WorkflowException
00053     ModuleSecurityInfo('Products.CMFCore.WorkflowCore').declarePublic('ObjectMoved')
00054     ModuleSecurityInfo('Products.CMFCore.WorkflowCore').declarePublic('ObjectDeleted')
00055     ModuleSecurityInfo('Products.CMFCore.WorkflowCore').declarePublic('WorkflowException')
00056     allow_class(ObjectMoved)
00057     allow_class(ObjectDeleted)
00058     allow_class(WorkflowException)
00059 
00060     from PloneBatch import Batch
00061     allow_class(Batch)
00062 
00063     # Make Batch available at module level
00064     this_module.Batch = Batch
00065 
00066     from StringIO import StringIO
00067     allow_class(StringIO)
00068 
00069     # Make listPolicies importable TTW
00070     ModuleSecurityInfo('Products.CMFPlone.Portal').declarePublic('listPolicies')
00071 
00072     # Make Unauthorized importable TTW
00073     ModuleSecurityInfo('AccessControl').declarePublic('Unauthorized')
00074 
00075     # Make ConflictError importable TTW
00076     ModuleSecurityInfo('ZODB.POSException').declarePublic('ConflictError')
00077 
00078     # Make ZCTextIndex ParseError importable TTW
00079     ModuleSecurityInfo('Products.ZCTextIndex.ParseTree').declarePublic('ParseError')
00080 
00081     # Make DateTimeError importable TTW
00082     ModuleSecurityInfo('DateTime.DateTime').declarePublic('DateTimeError')
00083     ModuleSecurityInfo('DateTime.DateTime').declarePublic('SyntaxError')
00084 
00085     # Make CopyError importable TTW
00086     ModuleSecurityInfo('OFS.CopySupport').declarePublic('CopyError')
00087 
00088     # Make DiscussionNotAllowed importable TTW
00089     ModuleSecurityInfo('Products.CMFDefault.DiscussionTool').declarePublic('DiscussionNotAllowed')
00090 
00091     # Make AllowSendto importable TTW
00092     ModuleSecurityInfo('Products.CMFPlone.PloneTool').declarePublic('AllowSendto')
00093 
00094     # Make ZCatalog's mergeResults importable TTW
00095     ModuleSecurityInfo('Products.ZCatalog.Catalog').declarePublic('mergeResults')
00096 
00097     # Make the navtree constructs available TTW
00098     allow_module('Products.CMFPlone.browser.navtree')
00099 
00100     # Allow access to the exception in the folder_delete script
00101     from OFS.ObjectManager import BeforeDeleteException
00102     allow_module('OFS.ObjectManager')
00103     allow_class(BeforeDeleteException)
00104 
00105     # Make cgi.escape available TTW
00106     ModuleSecurityInfo('cgi').declarePublic('escape')
00107 
00108     # Setup migrations
00109     import migrations
00110     migrations.executeMigrations()
00111     migrations.registerMigrations()
00112 
00113     # Inititalize configuration machinery
00114     import setup
00115 
00116     # Apply monkey patches
00117     import patches
00118 
00119     # Register unicode splitter w/ ZCTextIndex
00120     # pipeline registry
00121     import UnicodeSplitter
00122 
00123     # Register Plone skins directory
00124     from Products.CMFCore import DirectoryView
00125     DirectoryView.registerDirectory('skins', cmfplone_globals)
00126 
00127     # Plone content
00128 
00129     # LargePloneFolder is deprectated and will be removed in Plone 4.0.
00130     # Usage of PloneFolder is discouraged.
00131     import PloneFolder, LargePloneFolder
00132     import Portal
00133 
00134     contentClasses      = ( PloneFolder.PloneFolder,
00135                             LargePloneFolder.LargePloneFolder, )
00136     contentConstructors = ( PloneFolder.addPloneFolder,
00137                             LargePloneFolder.addLargePloneFolder, )
00138 
00139     # CMFCore and CMFDefault tools
00140     from Products.CMFCore import CachingPolicyManager
00141 
00142     # Plone tools
00143     import PloneTool, FactoryTool
00144     import InterfaceTool, MigrationTool, PloneControlPanel
00145     import MembershipTool, WorkflowTool, URLTool, MetadataTool
00146     import RegistrationTool, MemberDataTool, SyndicationTool
00147     import PropertiesTool, ActionsTool, TypesTool, UndoTool
00148     import CatalogTool, SkinsTool, DiscussionTool
00149     import CalendarTool, ActionIconsTool, QuickInstallerTool
00150     import GroupDataTool, GroupsTool
00151     import TranslationServiceTool
00152 
00153     tools = ( MembershipTool.MembershipTool,
00154               MemberDataTool.MemberDataTool,
00155               PloneTool.PloneTool,
00156               WorkflowTool.WorkflowTool,
00157               CachingPolicyManager.CachingPolicyManager,
00158               FactoryTool.FactoryTool,
00159               PropertiesTool.PropertiesTool,
00160               MigrationTool.MigrationTool,
00161               InterfaceTool.InterfaceTool,
00162               PloneControlPanel.PloneControlPanel,
00163               RegistrationTool.RegistrationTool,
00164               URLTool.URLTool,
00165               MetadataTool.MetadataTool,
00166               ActionsTool.ActionsTool,
00167               TypesTool.TypesTool,
00168               UndoTool.UndoTool,
00169               SyndicationTool.SyndicationTool,
00170               CatalogTool.CatalogTool,
00171               SkinsTool.SkinsTool,
00172               DiscussionTool.DiscussionTool,
00173               ActionIconsTool.ActionIconsTool,
00174               CalendarTool.CalendarTool,
00175               QuickInstallerTool.QuickInstallerTool,
00176               GroupsTool.GroupsTool,
00177               GroupDataTool.GroupDataTool,
00178               TranslationServiceTool.TranslationServiceTool,
00179             )
00180 
00181     from Products.CMFCore.utils import ContentInit
00182     from Products.CMFPlone.utils import ToolInit
00183 
00184     # Register tools and content
00185     ToolInit('Plone Tool'
00186              , tools=tools
00187              , icon='tool.gif'
00188              ).initialize( context )
00189 
00190     ContentInit('Plone Content'
00191                 , content_types=contentClasses
00192                 , permission=ADD_CONTENT_PERMISSION
00193                 , extra_constructors=contentConstructors
00194                 ).initialize( context )
00195 
00196     import factory
00197     context.registerClass(Portal.PloneSite,
00198                           constructors=(factory.addPloneSiteForm,
00199                                         factory.addPloneSite),
00200                           icon='skins/plone_images/logoIcon.gif')
00201 
00202 # Import "PloneMessageFactory as _" to create messages in the plone domain
00203 from zope.i18nmessageid import MessageFactory
00204 PloneMessageFactory = MessageFactory('plone')
00205 
00206 # Import PloneLocalesMessageFactory to create messages in the plonelocales domain
00207 from zope.i18nmessageid import MessageFactory
00208 PloneLocalesMessageFactory = MessageFactory('plonelocales')
00209 
00210 # A module alias for the stupidly named plone.py - now called 'ploneview.py'
00211 # 
00212 # If you get weird import errors like "Cannot import module 'utils'" (when 
00213 # trying to import Products.CMFPlone.utils, comment out the next two lines -
00214 # they may be masking the error.
00215 from browser import ploneview
00216 sys.modules['Products.CMFPlone.browser.plone'] = ploneview