Changeset 1287

Show
Ignore:
Timestamp:
04/24/08 19:08:36 (7 months ago)
Author:
sgillies
Message:

Initial content, browser, and profile components

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pleiades.workspace/trunk/pleiades/workspace/__init__.py

    r1285 r1287  
     1"""Main product initializer 
     2""" 
     3 
     4from zope.i18nmessageid import MessageFactory 
     5from pleiades.workspace import config 
     6 
     7from Products.Archetypes import atapi 
     8from 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 
     14WorkspaceMessageFactory = MessageFactory('pleiades.workspace') 
     15 
     16def initialize(context): 
     17    """Intializer called when used as a Zope 2 product. 
     18     
     19    This is referenced from configure.zcml. Regstrations as a "Zope 2 product"  
     20    is necessary for GenericSetup profiles to work, for example. 
     21     
     22    Here, we call the Archetypes machinery to register our content types  
     23    with Zope and the CMF. 
     24    """ 
     25     
     26    # Retrieve the content types that have been registered with Archetypes 
     27    # This happens when the content type is imported and the registerType() 
     28    # call in the content type's module is invoked. Actually, this happens 
     29    # during ZCML processing, but we do it here again to be explicit. Of  
     30    # course, even if we import the module several times, it is only run 
     31    # once! 
     32     
     33    from content import workspace 
     34     
     35    content_types, constructors, ftis = atapi.process_types( 
     36        atapi.listTypes(config.PROJECTNAME), 
     37        config.PROJECTNAME) 
     38 
     39    # Now initialize all these content types. The initialization process takes 
     40    # care of registering low-level Zope 2 factories, including the relevant 
     41    # add-permission. These are listed in config.py. We use different  
     42    # permisisons for each content type to allow maximum flexibility of who 
     43    # can add which content types, where. The roles are set up in rolemap.xml 
     44    # in the GenericSetup profile. 
     45 
     46    for atype, constructor in zip(content_types, constructors): 
     47        utils.ContentInit("%s: %s" % (config.PROJECTNAME, atype.portal_type), 
     48            content_types      = (atype,), 
     49            permission         = config.ADD_PERMISSIONS[atype.portal_type], 
     50            extra_constructors = (constructor,), 
     51            ).initialize(context) 
     52 
     53def createWorkspace(self, id, **kwargs): 
     54    import pdb; pdb.set_trace() 
     55    return id 
     56 
  • pleiades.workspace/trunk/pleiades/workspace/configure.zcml

    r1285 r1287  
    11<configure 
    2     xmlns="http://namespaces.zope.org/zope" 
    3     xmlns:five="http://namespaces.zope.org/five" 
    4     i18n_domain="pleiades.workspace"> 
     2  xmlns="http://namespaces.zope.org/zope" 
     3  xmlns:five="http://namespaces.zope.org/five" 
     4  xmlns:genericsetup="http://namespaces.zope.org/genericsetup" 
     5  i18n_domain="pleiades.workspace" 
     6  > 
    57 
     8  <five:registerPackage package="." initialize=".initialize" /> 
     9 
     10  <include package=".browser" /> 
     11  <include package=".content" /> 
     12 
     13  <genericsetup:registerProfile 
     14    name="default" 
     15    title="Pleiades Content Workspaces" 
     16    directory="profiles/default" 
     17    description="Content workspaces for Pleiades" 
     18    provides="Products.GenericSetup.interfaces.EXTENSION" 
     19    /> 
    620 
    721</configure>