source: trunk/__init__.py @ 495

Revision 495, 4.7 KB checked in by vahur, 13 years ago (diff)

made a list of content types. Also made config.py accessible from python scripts and page templates.

  • Property svn:eol-style set to native
Line 
1# Copyright 2006 by the LeMill Team (see AUTHORS)
2#
3# This file is part of LeMill.
4#
5# LeMill is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# LeMill is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with LeMill; if not, write to the Free Software
17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
19from config import *
20
21# CMF imports
22from Products.CMFCore import utils
23from Products.CMFCore.DirectoryView import registerDirectory
24from Products.CMFPlone import MigrationTool
25
26# BEGIN: PLONE 2.1 portion
27from Products.CMFPlone.Portal import addPolicy
28from Products.CMFPlone.interfaces.CustomizationPolicy import ICustomizationPolicy
29from Products.CMFPlone.CustomizationPolicy import DefaultCustomizationPolicy
30# END: PLONE 2.1 portion
31
32if PLONE25:
33    from Products.CMFPlone.interfaces import IPloneSiteRoot
34    from Products.GenericSetup import profile_registry, BASE, EXTENSION
35
36# Archetypes imports
37from Products.Archetypes.public import process_types, listTypes
38
39# Our own content types
40import Piece, Material, SectionFolder, Story, Activity, Tool, Collection, MemberFolder, GroupBlog, BlogPost
41import PresentationMaterial, MultimediaMaterial
42import Fle3Integration
43
44# Widgets
45from FieldsWidgets import MessengerWidget
46
47# Our own portal tools
48import LeMillSearchTool, LeMillTool, LeMillUserTool
49# Make a list of portal tools
50tools = (LeMillTool.LeMillTool, LeMillSearchTool.LeMillSearchTool, LeMillUserTool.LeMillUserTool)
51
52# Our own configuration stuff
53from ConfigurationMethods import LeMillSetup
54import LeMillWorkflow
55
56# HOOK: Anything executed here will be executed any time the product is refreshed
57# or Zope is restarted.
58
59# Add the skins folder to the registry of viewable folders
60registerDirectory(SKINS_DIR,GLOBALS)
61
62def initialize(context):
63    """This method is called when this product is initialized upon Zope startup."""
64
65    # Add our setup widgets into MigrationTool
66    MigrationTool.registerSetupWidget(LeMillSetup)
67
68    # making config accessible from python scripts.
69    from AccessControl import allow_module
70    allow_module('Products.LeMill.config')
71
72    # Register our extension profile / customization policy
73    if PLONE25:
74        try:
75            profile_registry.registerProfile(name='LeMill',
76                                             title='LeMill Legacy Site',
77                                             description="LeMill is a heavily customized Plone for special use, and can't be converted to a normal Plone very easily.",
78                                             path='profiles/legacy',
79                                             product='LeMill',
80                                             profile_type=EXTENSION,
81                                             for_=IPloneSiteRoot)
82        except KeyError:
83            # Already done - ignore
84            pass
85                                         
86    addPolicy('LeMill Site',LeMillCustomizationPolicy())
87
88    # Register our set of portal tools
89    utils.ToolInit(PROJECTNAME + ' Tools', tools=tools,
90        icon='skins/lemill/tool.gif',).initialize(context)
91
92    # Process all imported content types into nice lists
93    content_types, constructors, ftis = process_types(
94        listTypes(PROJECTNAME),
95        PROJECTNAME)
96
97    # Register our set of content types
98    utils.ContentInit(
99        PROJECTNAME + ' Content',
100        content_types      = content_types,
101        permission         = ADD_CONTENT_PERMISSION,
102        extra_constructors = constructors,
103        fti                = ftis,
104        ).initialize(context)
105
106
107class LeMillCustomizationPolicy(DefaultCustomizationPolicy):
108    """Customization policy for the LeMill site."""
109    __implements__ = ICustomizationPolicy
110
111    # Yes, this can be used when creating a new Plone instance
112    availableAtConstruction=True
113
114    def customize(self,portal):
115        """This method is called when a Plone portal is created with this
116        customization policy."""
117       
118        # Call super class, just in case they do something intelligent
119        DefaultCustomizationPolicy.customize(self,portal)
120       
121        # Locate our migration widget
122        widget = portal.portal_migration._getWidget('LeMill Setup')
123       
124        # Add and execute all configuration methods that it lists as being available
125        widget.addItems(widget.available())
Note: See TracBrowser for help on using the repository browser.