Back to index

plone3  3.1.7
__init__.py
Go to the documentation of this file.
00001 #  ATContentTypes http://plone.org/products/atcontenttypes/
00002 #  Archetypes reimplementation of the CMF core types
00003 #  Copyright (c) 2003-2006 AT Content Types development team
00004 #
00005 #  This program is free software; you can redistribute it and/or modify
00006 #  it under the terms of the GNU General Public License as published by
00007 #  the Free Software Foundation; either version 2 of the License, or
00008 #  (at your option) any later version.
00009 #
00010 #  This program is distributed in the hope that it will be useful,
00011 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 #  GNU General Public License for more details.
00014 #
00015 #  You should have received a copy of the GNU General Public License
00016 #  along with this program; if not, write to the Free Software
00017 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 #
00019 """ATContentTypes
00020 """
00021 __author__  = 'Christian Heimes <tiran@cheimes.de>'
00022 __docformat__ = 'restructuredtext'
00023 
00024 import os.path
00025 import sys
00026 import logging
00027 
00028 logger = logging.getLogger('ATCT')
00029 
00030 ATCT_DIR = os.path.abspath(os.path.dirname(__file__))
00031 sys.path.insert(3, os.path.join(ATCT_DIR, 'thirdparty'))
00032 
00033 __version__ = open(os.path.join(__path__[0], 'version.txt')).read().strip()
00034 
00035 from AccessControl import ModuleSecurityInfo
00036 
00037 from Products.ATContentTypes.config import HAS_LINGUA_PLONE
00038 from Products.ATContentTypes.config import SKINS_DIR
00039 from Products.ATContentTypes.config import PROJECTNAME
00040 from Products.ATContentTypes.config import GLOBALS
00041 
00042 if HAS_LINGUA_PLONE:
00043     from Products.LinguaPlone.public import process_types
00044     from Products.LinguaPlone.public import listTypes
00045 else:
00046     from Products.Archetypes.atapi import process_types
00047     from Products.Archetypes.atapi import listTypes
00048 
00049 from Products.CMFCore.utils import ContentInit
00050 from Products.CMFCore.utils import ToolInit
00051 from Products.CMFCore.DirectoryView import registerDirectory
00052 
00053 # Import "ATCTMessageFactory as _" to create messages in atcontenttypes domain
00054 from zope.i18nmessageid import MessageFactory
00055 ATCTMessageFactory = MessageFactory('atcontenttypes')
00056 ModuleSecurityInfo('Products.ATContentTypes').declarePublic('ATCTMessageFactory')
00057 
00058 # first level imports: configuration and validation
00059 import Products.ATContentTypes.configuration
00060 import Products.ATContentTypes.lib.validators
00061 
00062 # second leven imports: content types, criteria
00063 # the content types are depending on the validators and configuration
00064 import Products.ATContentTypes.content
00065 import Products.ATContentTypes.criteria
00066 
00067 # misc imports
00068 from Products.ATContentTypes.tool.atct import ATCTTool
00069 
00070 # wire the add permission after all types are registered
00071 from Products.ATContentTypes.permission import wireAddPermissions
00072 wireAddPermissions()
00073 
00074 # setup module aliases for old dotted pathes
00075 import Products.ATContentTypes.modulealiases
00076 
00077 registerDirectory(SKINS_DIR,GLOBALS)
00078 
00079 def initialize(context):
00080     # process our custom types
00081 
00082     ToolInit(
00083         'ATContentTypes tool',
00084         tools=(ATCTTool,),
00085         icon='tool.gif', ).initialize(context)
00086 
00087     listOfTypes = listTypes(PROJECTNAME)
00088 
00089     content_types, constructors, ftis = process_types(
00090         listOfTypes,
00091         PROJECTNAME)
00092 
00093     # Assign an own permission to all content types
00094     # Heavily based on Bricolite's code from Ben Saller
00095     from Products.ATContentTypes.permission import permissions
00096 
00097     allTypes = zip(content_types, constructors)
00098     for atype, constructor in allTypes:
00099         kind = "%s: %s" % (PROJECTNAME, atype.archetype_name)
00100         ContentInit(
00101             kind,
00102             content_types      = (atype,),
00103             permission         = permissions[atype.portal_type],
00104             extra_constructors = (constructor,),
00105             ).initialize(context)
00106