Changeset 1428

Show
Ignore:
Timestamp:
11/20/08 09:04:01
Author:
mylan
Message:

Add Sitemap content type

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneGoogleSitemaps/branches/contenttype/__init__.py

    r1089 r1428  
    99allow_module('Products.qPloneGoogleSitemaps.utils.py') 
    1010allow_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 import utils 
     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        utils.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) 
  • qPloneGoogleSitemaps/branches/contenttype/config.py

    r8 r1428  
     1"""Common configuration constants 
     2""" 
     3 
     4PROJECTNAME = 'qPloneGoogleSitemaps' 
     5 
     6ADD_PERMISSIONS = { 
     7    # -*- extra stuff goes here -*- 
     8    'Sitemap': 'qPloneGoogleSitemaps: Add Sitemap', 
     9} 
     10 
    111ping_googlesitemap = 'ping_googlesitemap'