##############################################################################
# Copyright (c) 2004-2005 Black Rock City, LLC
# Copyright (c) 2004-2005 ObjectRealms, LLC
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
##############################################################################
"""
$Id: __init__.py 46903 2007-08-09 05:57:19Z rafrombrc $
"""

from config import *
from Globals import package_home
from Products.Archetypes import process_types, listTypes
from Products.CMFCore.DirectoryView import registerDirectory
from Products.CMFCore import utils as cmf_utils


import exceptions, membership, relations, roster, tool, space, workflows
from permissions import initialize as initialize_permissions

registerDirectory('skins', GLOBALS)

if MONKEY_PATCH_CALENDAR_TOOL:
    import calendar_patch

def initialize( context ):

    content_types, constructors, ftis = process_types( listTypes(PKG_NAME),
                                                       PKG_NAME )

    # this policy enables manager to install TeamSpace and team-centric
    # roles and workflows at Plone site creation
    from policies import BasicTeamPolicy
    BasicTeamPolicy.register(context, GLOBALS)

    permissions = initialize_permissions()
    allTypes = zip(content_types, constructors)
    for atype, constructor in allTypes:
        kind = "%s: %s" % (PKG_NAME, atype.archetype_name)
        cmf_utils.ContentInit(
            kind,
            content_types = (atype,),
            permission    = permissions[atype.portal_type],
            extra_constructors = (constructor,),
            fti = ftis,
            ).initialize( context )
        
    cmf_utils.ToolInit(
        "%s Tool" % PKG_NAME,
        tools = (tool.TeamsTool,),
        icon = "tool.png",
        ).initialize( context )
