source: products/quintagroup.plonegooglesitemaps/branches/migratioin_product/quintagroup/plonegooglesitemaps/__init__.py @ 2826

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

#230: Added module aliases - prevent breakage sitemap, created with qPloneGoogleSitemaps

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