Back to index

plone3  3.1.7
dependencies.py
Go to the documentation of this file.
00001 import logging
00002 import sys
00003 
00004 MINIMUM_PYTHON_VER = (2, 4, 3)
00005 PREFERRED_PYTHON_VER = "2.4.4 or newer"
00006 
00007 MINIMUM_ZOPE_VER = (2, 10, 4)
00008 PREFERRED_ZOPE_VER = "2.10.4 or newer"
00009 
00010 MINIMUM_CMF_VER = (2, 1, 0)
00011 
00012 messages = []
00013 
00014 def log(message, summary='', severity=logging.ERROR, optional=0):
00015     if optional:
00016         subsys = 'Plone Option'
00017     else:
00018         subsys = 'Plone Dependency'
00019     messages.append({'message' : message, 'summary' : summary,
00020                      'severity' : severity, 'optional' : optional
00021             })
00022     logger = logging.getLogger(subsys)
00023     logger.log(severity, '%s \n%s', summary, message)
00024 
00025 # test python version
00026 PYTHON_VER = sys.version_info[:3]
00027 if PYTHON_VER < MINIMUM_PYTHON_VER:
00028     log(("Python version %s found but Plone needs at least "
00029          "Python %s. Please download and install Python %s "
00030      "from http://python.org/" % (PYTHON_VER,
00031      MINIMUM_PYTHON_VER, PREFERRED_PYTHON_VER) ))
00032 
00033 # test zope version
00034 ZOPE_VER = "unknown"
00035 try:
00036     from App.version_txt import getZopeVersion
00037 except ImportError:
00038     pass
00039 else:
00040     try:
00041         ZOPE_VER = getZopeVersion()[:3]
00042     except (ValueError, TypeError, KeyError):
00043         pass
00044 
00045 if ZOPE_VER in ('unknown', (-1, -1, -1)): # -1, -1, 1 is developer release
00046     log(("Unable to detect Zope version. Please make sure you have Zope "
00047          "%s installed." % PREFERRED_ZOPE_VER), severity=logging.INFO)
00048 elif ZOPE_VER < MINIMUM_ZOPE_VER:
00049     log(("Zope version %s found but Plone needs at least "
00050          "Zope %s Please download and install Zope %s "
00051      "from http://zope.org/" %
00052      ('.'.join([str(x) for x in ZOPE_VER]),
00053        '.'.join([str(x) for x in MINIMUM_ZOPE_VER]), PREFERRED_ZOPE_VER) ))