##############################################################################
# Copyright (c) 2005 The Open Planning Project and Rob Miller
# All Rights Reserved.
#
# This software is subject to the provisions of the GNU General Public
# License, Version 2.0 (GPL).  A copy of the GPL 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.
##############################################################################
"""
Product bootstrapping and initialization.

$Id: __init__.py 15510 2006-01-05 21:55:41Z rafrombrc $
"""

from Products.CMFCore import utils as cmfutils, DirectoryView
from Products.Archetypes import process_types, listTypes
from Products.Archetypes import public as atapi
from config import PROJECT_NAME, GLOBALS

DirectoryView.registerDirectory('skins', GLOBALS)

import tools
from permissions import initialize as initialize_permissions

import patches

def initialize(context):
    content_types, constructors, ftis = process_types( listTypes(PROJECT_NAME),
                                                       PROJECT_NAME )

    permissions = initialize_permissions()
    allTypes = zip(content_types, constructors)
    for atype, constructor in allTypes:
        kind = "%s: %s" % (PROJECT_NAME, atype.archetype_name)
        cmfutils.ContentInit(
            kind,
            content_types=(atype,),
            permission=permissions[atype.portal_type],
            extra_constructors=(constructor,),
            fti=ftis,
            ).initialize(context)

    cmfutils.ToolInit(
        '%s Tool' % PROJECT_NAME,
        tools=(tools.AnonymailerTool,),
        product_name=PROJECT_NAME,
        icon="tool.png",
        ).initialize(context)
