source: products/quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/__init__.py @ 1617

Last change on this file since 1617 was 1617, checked in by mylan, 9 years ago

Fix typo

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