root/trunk/__init__.py

Revision 3014, 6.0 kB (checked in by jukka, 2 years ago)

Preparing for new i18n extraction and removing references to kupu, next commit will replace it with tinyMCE.

  • 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
19 from config import *
20 import config
21
22 # CMF imports
23 from Products.CMFCore import utils
24 from Products.CMFCore.DirectoryView import registerDirectory, registerFileExtension
25 from Products.CMFPlone import MigrationTool
26
27 # BEGIN: PLONE 2.1 portion
28 from Products.CMFPlone.Portal import addPolicy
29 from Products.CMFPlone.interfaces.CustomizationPolicy import ICustomizationPolicy
30 from Products.CMFPlone.CustomizationPolicy import DefaultCustomizationPolicy
31 # END: PLONE 2.1 portion
32
33 if PLONE25:
34     from Products.CMFPlone.interfaces import IPloneSiteRoot
35     from Products.GenericSetup import profile_registry, BASE, EXTENSION
36
37 # Zope's HTTPResponse uses iso-8859-15 as its default encoding
38 # This is not normally used if the HTTPResponse knows which encoding
39 # has been requested. However, for status messages the headers are
40 # not set, so we need to hack the default to utf-8.
41 from ZPublisher import HTTPResponse
42 HTTPResponse.default_encoding='utf-8'
43
44 #XXX KALA
45
46 from Products.CMFCore.FSFile import FSFile
47 registerFileExtension ('ttf', FSFile)
48 registerFileExtension ('xml', FSFile)
49
50 # Import "LeMillMessageFactory as _" to create message ids in the plone domain
51 # Zope 3.1-style messagefactory module
52 # BBB: Zope 2.8 / Zope X3.0
53 try:
54     from zope.i18nmessageid import MessageFactory
55 except ImportError:
56     from messagefactory_ import LeMillMessageFactory
57 else:
58     LeMillMessageFactory = MessageFactory('lemill')
59
60 from messagefactory_ import i18nme
61
62 # Provide backward compatibility for products relying on this import location
63 # BBB: Remove in Plone 3.0
64 import transaction
65
66
67 # Archetypes imports
68 from Products.Archetypes.public import process_types, listTypes
69
70 # Our own content types
71 import Piece, Material, LargeSectionFolder, Activity, Tool, Collection, MemberFolder, GroupBlog, BlogPost
72 import PresentationMaterial, MultimediaMaterial, ExerciseMaterial, LessonPlan, SchoolProjectMaterial
73 import CommonMixIn, Resource, LearningResource, Discussable
74 import LeMillReference, PILOTMaterial, LeMillPrintResource
75 from CommonMixIn import Redirector
76
77 # Our own portal tools
78 import LeMillSearchTool, LeMillTool, LeMillUserTool, LatexTool, LeMillFactoryTool, LeMillCatalogTool, MaintenanceTool
79 # Make a list of portal tools
80 tools = (LeMillTool.LeMillTool, LeMillSearchTool.LeMillSearchTool, LeMillUserTool.LeMillUserTool, LatexTool.LatexTool, LeMillFactoryTool.FactoryTool, LeMillCatalogTool.CatalogTool, MaintenanceTool.MaintenanceTool)
81
82 # Our own configuration stuff
83 from ConfigurationMethods import LeMillSetup
84
85 # HOOK: Anything executed here will be executed any time the product is refreshed
86 # or Zope is restarted.
87
88 # Add the skins folder to the registry of viewable folders
89 registerDirectory(SKINS_DIR,GLOBALS)
90
91 def initialize(context):
92     """This method is called when this product is initialized upon Zope startup."""
93
94     # Add our setup widgets into MigrationTool
95     MigrationTool.registerSetupWidget(LeMillSetup)
96
97     # making config accessible from python scripts.
98     from AccessControl import allow_module, ModuleSecurityInfo
99     #ModuleSecurityInfo('config').declarePublic()
100     #allow_module('Products.LeMill.config')
101     allow_module('Products.LeMill.Validators')
102
103     # Register our extension profile / customization policy
104     if PLONE25:
105         try:
106             profile_registry.registerProfile(name='LeMill',
107                                              title='LeMill Site',
108                                              description="LeMill is a heavily customized Plone for special use, and can't be converted to a normal Plone very easily.",
109                                              path='profiles/legacy',
110                                              product='LeMill',
111                                              profile_type=EXTENSION,
112                                              for_=IPloneSiteRoot)
113         except KeyError:
114             # Already done - ignore
115             pass
116                                          
117     addPolicy('LeMill Site',LeMillCustomizationPolicy())
118
119     # Register our set of portal tools
120     utils.ToolInit(PROJECTNAME + ' Tools', tools=tools,
121         icon='skins/lemill/tool.gif',).initialize(context)
122
123     # Process all imported content types into nice lists
124     content_types, constructors, ftis = process_types(
125         listTypes(PROJECTNAME),
126         PROJECTNAME)
127
128     # Register our set of content types
129     utils.ContentInit(
130         PROJECTNAME + ' Content',
131         content_types      = content_types,
132         permission         = ADD_CONTENT_PERMISSION,
133         extra_constructors = constructors,
134         fti                = ftis,
135         ).initialize(context)
136
137
138 class LeMillCustomizationPolicy(DefaultCustomizationPolicy):
139     """Customization policy for the LeMill site."""
140     __implements__ = ICustomizationPolicy
141
142     # Yes, this can be used when creating a new Plone instance
143     availableAtConstruction=True
144
145     def customize(self,portal):
146         """This method is called when a Plone portal is created with this
147         customization policy."""
148        
149         # Call super class, just in case they do something intelligent
150         DefaultCustomizationPolicy.customize(self,portal)
151        
152         # Locate our migration widget
153         widget = portal.portal_migration._getWidget('LeMill Setup')
154        
155         # Add and execute all configuration methods that it lists as being available
156         widget.addItems(widget.available())
Note: See TracBrowser for help on using the browser.