Back to index

plone3  3.1.7
__init__.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2003-2005 Kupu Contributors. All rights reserved.
00004 #
00005 # This software is distributed under the terms of the Kupu
00006 # License. See LICENSE.txt for license text. For a list of Kupu
00007 # Contributors see CREDITS.txt.
00008 #
00009 ##############################################################################
00010 """kupu package initialization
00011 
00012 This module does some twirks to let us use kupu with Zope2, CMF/Plone
00013 and Zope3
00014 
00015 $Id: __init__.py 54400 2008-05-04 12:42:54Z hannosch $
00016 """
00017 
00018 # we need this for the CMF install script
00019 kupu_globals = globals()
00020 
00021 # test for Zope2
00022 try:
00023     import Zope2 as Zope
00024     have_zope2 = 1
00025 except ImportError:
00026     have_zope2 = 0
00027     
00028 if not have_zope2:
00029     try:
00030         import Zope
00031         have_zope2 = 1
00032     except ImportError:
00033         have_zope2 = 0
00034 
00035 # test for CMF
00036 try:
00037     import Products.CMFCore
00038     have_cmf = 1
00039 except ImportError:
00040     have_cmf = 0
00041 
00042 # test for Plone
00043 try:
00044     import Products.CMFPlone
00045     have_plone = 1
00046 except ImportError:
00047     have_plone = 0
00048 
00049 # test for FileSystemSite
00050 try:
00051     import Products.FileSystemSite
00052     have_fss = 1
00053 except ImportError:
00054     have_fss = 0
00055 
00056 # do the minimal stuff for skin registering
00057 # note that CMF/Plone users will still have to run the
00058 # Extensions/Install.py script
00059 if have_cmf:
00060     # Need to do this in case Archetypes isn't present.
00061     from Products.CMFCore.FSFile import FSFile
00062     from Products.CMFCore.DirectoryView import registerFileExtension, registerDirectory
00063     registerFileExtension('xsl', FSFile)
00064     registerDirectory('common', globals())
00065 
00066     if have_plone:
00067         from Products.kupu.plone import initialize
00068 
00069 elif have_zope2 and have_fss:
00070     import zope2
00071     initialize = zope2.initialize
00072 
00073 if have_zope2:
00074     # in Zope 2, make all modules in the 'python' lib available
00075     def __allow_access_to_unprotected_subobjects__(name, value=None):
00076         return name in ('python')
00077 
00078     from AccessControl import allow_module
00079     allow_module('Products.kupu.python.nationalizer')
00080     allow_module('Products.kupu.python.spellcheck')
00081 
00082 # do nothing for zope3 (all is done in zcml)