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