#-*- mode: python; mode: fold -*-
# $Id: __init__.py 3824 2008-12-19 15:44:45Z henrik $
from Products.CMFCore.utils import ContentInit, ToolInit
from Products.CMFCore.DirectoryView import registerDirectory
from Products.CMFCore import utils as cmfutils
from Products.CMFCore.permissions import AddPortalContent

from Products.GenericSetup import profile_registry
from Products.GenericSetup import EXTENSION
from Products.GenericSetup import BASE

from Products.CPSCore.interfaces import ICPSSite
from Products.CPSDirectory.DirectoryTool import DirectoryTypeRegistry

import patches

import Products.WAeUP_SRP.WAeUPPermissions
import WAeUPTool

import Widgets
tools = (WAeUPTool.WAeUPTool,)

waeup_types = (
    ("University",
       ('University',
        'WAeUPConfiguration',
        )
    ),
    ("Academics",
       ("AcademicsFolder",
        "Certificate",
        "CertificateCourse",
        "Faculty",
        "Department",
        "Course",
        "CertificateCourse",
        "StudyLevel",
        )
     ),
     ("Accommodation",
        ("AccoFolder",
         "AccoHall",
         )
     ),
     ("Payment",
        ("PaymentsFolder",
         "Payment",
         )
     ),
     ("Students",
        ("StudentsFolder",
         "Student",
         "StudentAccommodation",
         "StudentStudyCourse",
         "StudentCourseResult",
         "StudentApplication",
         "StudentPume",
         "StudentClearance",
         "StudentPersonal",
         "StudentStudyLevel",
         #"Semester",
         "StudentCourseResult",
         "StudentPastoralReport",
         # move to Academics later
         #"Semester",
         )
      ),
     ("ScratchCards",
         ("ScratchCardBatch",
          "ScratchCardBatchesFolder",
         )
     ),
     ("Documents",
        ("DocumentsFolder",
         "WAeUPDocument",
        )
     ),
     ("Upload",
        ("UploadsFolder",
         "Upload",
         )
     ),
    )

contentClasses = []
cc = []
for modu,names in waeup_types:
    mod = __import__('Products.WAeUP_SRP.%(modu)s' % vars(),
                globals(),
                locals(),
                ['*',]
                )
    for name in names:
        #print name
        contentClasses.append(getattr(mod,name))
        cc.append(getattr(mod,"add%(name)s" % vars()))
contentConstructors = tuple(cc)

fti = [{} for t in range(len(contentConstructors))]

registerDirectory('skins', globals())

def initialize(registrar):
    ToolInit('WAeUP Tool',
              tools=tools,
              icon='tool.gif',
              ).initialize(registrar)
    ContentInit('WAeUP Types',
                content_types = contentClasses,
                permission = AddPortalContent,
                extra_constructors = contentConstructors,
                fti = fti,
                ).initialize(registrar)

    # profile registration
    profile_registry.registerProfile(
        'default',
        'WAeUP_SRP',
        "WAeUP Default Profile",
        'profiles/default',
        'WAeUP_SRP',
        BASE,
        for_=ICPSSite)
    profile_registry.registerProfile(
        'uniben',
        'WAeUP Uniben Profile',
        "University of Benin",
        'profiles/uniben',
        'WAeUP_SRP',
        EXTENSION,
        for_=ICPSSite)        
    profile_registry.registerProfile(
        'fceokene',
        'WAeUP FCE Okene Profile',
        "Federal College of Education",
        'profiles/fceokene',
        'WAeUP_SRP',
        EXTENSION,
        for_=ICPSSite)       
    profile_registry.registerProfile(
        'aaua',
        'WAeUP AAUA Profile',
        "Adekunle Ajasin University",
        'profiles/aaua',
        'WAeUP_SRP',
        EXTENSION,
        for_=ICPSSite)   
    profile_registry.registerProfile(
        'unilorin',
        'WAeUP Unilorin Profile',
        "University of Ilorin",
        'profiles/unilorin',
        'WAeUP_SRP',
        EXTENSION,
        for_=ICPSSite)   
    profile_registry.registerProfile(
        'ois',
        'WAeUP OIS Profile',
        "Olashore International School",
        'profiles/ois',
        'WAeUP_SRP',
        EXTENSION,
        for_=ICPSSite)        
    profile_registry.registerProfile(
        'fceoyo',
        'WAeUP FCE Oyo Profile',
        "Federal College of Education",
        'profiles/fceoyo',
        'WAeUP_SRP',
        EXTENSION,
        for_=ICPSSite)       
    profile_registry.registerProfile(
        'aaue',
        'WAeUP AAUE Profile',
        "Ambrose Alli University",
        'profiles/aaue',
        'WAeUP_SRP',
        EXTENSION,
        for_=ICPSSite)  
    profile_registry.registerProfile(
        'futminna',
        'WAeUP FUT Minna Profile',
        "Federal University of Technology",
        'profiles/futminna',
        'WAeUP_SRP',
        EXTENSION,
        for_=ICPSSite)       
    profile_registry.registerProfile(
        'nau',
        'WAeUP NAU Awka Profile',
        "Nnamdi Azikiwe University",
        'profiles/nau',
        'WAeUP_SRP',
        EXTENSION,
        for_=ICPSSite)                                                
##    DirectoryTypeRegistry.register(WAeUPTables.Applicants)

    # Create a faster session container in temp_folder...
    import Zope
    from Products.faster.sessiondata import addSessionDataContainer
    sess_container_name = "faster_session"
    root = Zope.app()
    temp = root.unrestrictedTraverse( "/temp_folder", None )
    if temp is not None and not sess_container_name in temp.objectIds():
        addSessionDataContainer( temp, sess_container_name, 9600, 4800,
                  lazy=True, title='Faster session data container')

