[1593] | 1 | from AccessControl import allow_module |
---|
| 2 | |
---|
| 3 | allow_module('quintagroup.plonegooglesitemaps.utils.py') |
---|
| 4 | allow_module('quintagroup.plonegooglesitemaps.config.py') |
---|
| 5 | |
---|
| 6 | from zope.i18nmessageid import MessageFactory |
---|
| 7 | from quintagroup.plonegooglesitemaps import config |
---|
| 8 | |
---|
| 9 | from Products.Archetypes import atapi |
---|
| 10 | from Products.CMFCore.utils import ContentInit |
---|
| 11 | from 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 | |
---|
| 17 | qPloneGoogleSitemapsMessageFactory = MessageFactory('qPloneGoogleSitemaps') |
---|
| 18 | |
---|
[1591] | 19 | def initialize(context): |
---|
[1593] | 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) |
---|