source: products/qPloneGoogleSitemaps/trunk/__init__.py @ 3309

Last change on this file since 3309 was 458, checked in by fenix, 18 years ago

qPloneResolveUID import

File size: 2.4 KB
Line 
1import Globals
2
3from Products.CMFCore.DirectoryView import registerDirectory
4from AccessControl import allow_module
5
6registerDirectory('skins', globals())
7qPGS_globals = globals()
8
9allow_module('Products.qPloneGoogleSitemaps.utils.py')
10allow_module('Products.qPloneGoogleSitemaps.config.py')
11
12from zope.i18nmessageid import MessageFactory
13from Products.qPloneGoogleSitemaps import config
14
15from Products.Archetypes import atapi
16from Products.CMFCore.utils import ContentInit
17from Products.CMFCore.permissions import setDefaultRoles
18
19# Define a message factory for when this product is internationalised.
20# This will be imported with the special name "_" in most modules. Strings
21# like _(u"message") will then be extracted by i18n tools for translation.
22
23qPloneGoogleSitemapsMessageFactory = MessageFactory('qPloneGoogleSitemaps')
24
25def initialize(context):
26    """Initializer called when used as a Zope 2 product.
27
28    This is referenced from configure.zcml. Regstrations as a "Zope 2 product"
29    is necessary for GenericSetup profiles to work, for example.
30
31    Here, we call the Archetypes machinery to register our content types
32    with Zope and the CMF.
33    """
34
35    # Retrieve the content types that have been registered with Archetypes
36    # This happens when the content type is imported and the registerType()
37    # call in the content type's module is invoked. Actually, this happens
38    # during ZCML processing, but we do it here again to be explicit. Of
39    # course, even if we import the module several times, it is only run
40    # once.
41
42    content_types, constructors, ftis = atapi.process_types(
43        atapi.listTypes(config.PROJECTNAME),
44        config.PROJECTNAME)
45
46    # Now initialize all these content types. The initialization process takes
47    # care of registering low-level Zope 2 factories, including the relevant
48    # add-permission. These are listed in config.py. We use different
49    # permissions for each content type to allow maximum flexibility of who
50    # can add which content types, where. The roles are set up in rolemap.xml
51    # in the GenericSetup profile.
52
53    for atype, constructor in zip(content_types, constructors):
54        ContentInit('%s: %s' % (config.PROJECTNAME, atype.portal_type),
55            content_types      = (atype,),
56            permission         = config.ADD_PERMISSIONS[atype.portal_type],
57            extra_constructors = (constructor,),
58            ).initialize(context)
Note: See TracBrowser for help on using the repository browser.