Back to index

plone3  3.1.7
fiveconfig.py
Go to the documentation of this file.
00001 '''\
00002 Compatibility configuration switches
00003 
00004 This is a transitional solution to attack the problem
00005 of quickly changing Zope3 and Five APIs.
00006 
00007 Import checks are done centrally from here.
00008 The point is that compatibility imports should fail here,
00009 if anything goes wrong. Components should only check
00010 the switches set from here.
00011 
00012 Corresponding configuration features are also set up
00013 from the compat.zcml file. The idea is that all switches
00014 are accessible both from python and zcml.
00015 
00016 
00017 Supported versions:
00018 -------------------
00019 
00020 Zope  2.9, 2.10
00021 Zope  3.2, 3.3
00022 
00023 Compatibility matrix
00024 --------------------
00025 
00026 The following table shows which Five version can and should be used 
00027 with which Zope 2 and Zope 3 versions.
00028 
00029 .           Zope 2.8         Zope 2.9     Zope 2.10
00030 .           Zope X3 3.0      Zope 3.2     Zope 3.3  
00031 Five 1.0    included                               
00032 Five 1.2    X                                      
00033 Five 1.3                     included              
00034 Five 1.4                     X                      
00035 Five trunk                                included 
00036 
00037 '''
00038 
00039 __all__ = ('__compat__', )
00040 
00041 class DictLike(object):
00042     pass
00043     
00044 __compat__ = DictLike()
00045 
00046 try:
00047     import zope.component.interface
00048     # XXX this now fails on Zope 3.4, so
00049     # commented out even if it gives bad result now
00050     ##import zope.component.location
00051     __compat__.zope_pre_3_3 = False
00052 except ImportError:
00053     # The only supported pre_3_3 version is 3.2
00054     import zope.app.component.interface
00055     ##import zope.app.location
00056     __compat__.zope_pre_3_3 = True
00057     
00058 try:
00059     import Products.Five
00060 except ImportError:
00061     __compat__.five = False
00062 else:
00063     __compat__.five = True
00064     try:
00065         # Zope 2.8 / Five 1.0.2
00066         from Products.Five.resource import Resource
00067         __compat__.five_pre_1_3 = True
00068     except ImportError:
00069         # Zope 2.9 / Five 1.3
00070         from Products.Five.browser.resource import Resource
00071         __compat__.five_pre_1_3 = False
00072 
00073 # Unsupported versions.
00074 if __compat__.five and __compat__.five_pre_1_3:
00075     raise Exception, 'Zope 2.8 or prior versions (Five 1.2 or prior versions) are unsupported, please upgrade!'