"""

    DataGridField initialzer.

    Copyright 2006-2007 DataGridField authors.
    
    Load all submodules and perform Zope security initialize for them.

"""

from __future__ import nested_scopes
__author__ = "Mikko Ohtamaa <mikko@redinnovation.com>"
__docformat__ = 'epytext'


# Plone imports
from Products.CMFCore.DirectoryView import registerDirectory
from Products.CMFCore.permissions import AddPortalContent
from Products.CMFCore.utils import getToolByName, ContentInit
from Products.CMFCore.DirectoryView import registerDirectory
from Products.Archetypes.public import *
from Products.Archetypes import listTypes

# Local imports
from Products.DataGridField.DataGridWidget  import DataGridWidget
from Products.DataGridField.DataGridField  import DataGridField
from Products.DataGridField.DataGridField  import FixedRow
from Products.DataGridField.Column import Column
from Products.DataGridField.SelectColumn import SelectColumn
from Products.DataGridField.RadioColumn import RadioColumn
from Products.DataGridField.FixedColumn import FixedColumn
from Products.DataGridField.LinkColumn import LinkColumn
from Products.DataGridField.HelpColumn import HelpColumn
from Products.DataGridField.CheckboxColumn import CheckboxColumn
from Products.DataGridField import validators
from Products.DataGridField.utils import *

from config import INSTALL_DEMO_TYPES, PKG_NAME, SKIN_NAME, GLOBALS, DEBUG


def initialize(context):
    # register directory views
    registerDirectory('skins', GLOBALS)

    # Install new content types if run under unit tests or as example
    if INSTALL_DEMO_TYPES:
        import examples

        # content initialization
        content_types, constructors, ftis = process_types(listTypes(PKG_NAME), PKG_NAME,)

        ContentInit(
            '%s Content' % PKG_NAME,
            content_types = content_types,
            permission = AddPortalContent,
            extra_constructors = constructors,
            fti = ftis,
            ).initialize(context)

