##############################################################################
#
# Copyright (c) 2003 Epoz Contributors. See CREDITS.txt
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""epoz package initialization

This module does some twirks to let us use epoz with Zope2, CMF/Plone
and Zope3

$Id: __init__.py 2843 2004-01-20 11:21:53Z guido $
"""

# we need this for the CMF install script
epoz_globals = globals()

# test for Zope2
try:
    import Zope
    have_zope2 = 1
except ImportError:
    have_zope2 = 0

# test for CMF
try:
    import Products.CMFCore
    have_cmf = 1
except ImportError:
    have_cmf = 0

# test for Plone, removed because Plone isn't supported yet
try:
    import Products.CMFPlone
    have_plone = 1
except ImportError:
    have_plone = 0

# test for FileSystemSite
try:
    import Products.FileSystemSite
    have_fss = 1
except ImportError:
    have_fss = 0

# do the minimal stuff for skin registering
# note that CMF/Plone users will still have to run the
# Extensions/Install.py script
if have_cmf:
    from Products.CMFCore.DirectoryView import registerDirectory
    registerDirectory('common', globals())
    if have_plone:
        registerDirectory('plone', globals())
elif have_zope2 and have_fss:
    import zope2
    initialize = zope2.initialize

# do nothing for zope3 (all is done in zcml)

