[Zope-CMF] adding two types with different permissions

Karl Anderson kra@monkey.org
29 Jul 2002 12:53:53 -0700


I'm trying to add two types from the same Zope product.  Because I
want separate permissions for each's constructors, I'm using two
ContentInit calls.  However, this isn't working.

The Post ContentInit call below seems to wreck everything.  Starting
Zope with the code below in the shared __init__.py causes neither type
to show up in the types tool.  If I comment out the Post ContentInit,
the forum type gets added.  If I use only the commented-out
ContentInit that inits both, it works as well, but I can't use a
separate permission in that case.

I'm not getting a startup error or any indication of failure in the
console that starts Zope.

Seems like Post is wrecking it, of course, but then why is the double
init working?

factory_type_informations from both products appended.


from __init__.py:

def initialize( context ):

    #utils.ContentInit( 'CMF Forum Content My',
    #                   content_types = (Forum.ForumMy, Post.PostMy),
    #                   permission = 'Add portal content',
    #                   extra_constructors = (Forum.addForum, Post.addPost),
    #                   fti = (Forum.factory_type_information,
    #                          Post.factory_type_information)
    #                 ).initialize( context )
    utils.ContentInit( 'CMF Forum My',
                       content_types = (Forum.ForumMy,),
                       permission = 'Add portal content',
                       extra_constructors = (Forum.addForum,),
                       fti = (Forum.factory_type_information,)
                     ).initialize( context )
    utils.ContentInit( 'CMF Post My',
                       content_types = (Post.PostMy,),
                       permission = 'Add portal content',
                       extra_constructors = (Post.addPost,),
                       fti = (Post.factory_type_information,)
                     ).initialize( context )






from Post.py:

factory_type_information =   { 'id'             : 'PostMy'
                             , 'portal_type'    : 'PostMy'
                             , 'meta_type'      : 'PostMy'
                             , 'description'    : """\
Posts are like Discussion items but they just can be added into Forums."""
                             , 'icon'           : 'icon_post.gif'
                             , 'product'        : 'CMFForumMy'
                             , 'factory'        : 'addPost'
                             , 'filter_content_types' : 1
                             , 'allowed_content_types' : ('PostMy', ) 
                             #, 'immediate_view' : 'metadata_edit_form'
                             , 'immediate_view' : 'cwip_metadata_edit_form'
                             , 'global_allow'   : 0                               
                             , 'actions'        :
                                ( { 'id'            : 'view' 
                                  , 'name'          : 'View'
                                  , 'action'        : 'post_view'
                                  , 'permissions'   : (
                                      View, )
                                  }
                                , { 'id'            : 'post_reply'
                                  , 'name'          : 'Reply'
                                  , 'action'        : 'forum_post_message'
                                  , 'permissions'   : (
                                      AddPortalContent, )
                                  }
                                , { 'id'            : 'metadata'
                                  , 'name'          : 'Metadata'
                                  , 'action'        : 'cwip_metadata_edit_form'
                                  , 'permissions'   : (ModifyPortalContent, )
                                  }
                                )
                             }


from Forum.py:


factory_type_information = { 'id'             : 'ForumMy'
                             , 'portal_type'	: 'ForumMy'
                             , 'meta_type'      : 'ForumMy'
                             , 'description'    : \
                             "Forums hold threaded discussions."
                             , 'icon'           : 'forum_icon.gif'
                             , 'product'        : 'CMFForumMy'
                             , 'factory'        : 'addForum'
                             , 'filter_content_types' : 1
                             , 'allowed_content_types' : ('PostMy', )
                             , 'immediate_view' : 'cwip_metadata_edit_form'
                             #, 'immediate_view' : 'forum_edit_form'
                             , 'actions'        :
                                ( { 'id'            : 'view'
                                  , 'name'          : 'View'
                                  , 'action'        : 'forum_listing'
                                  , 'permissions'   : (View,)
                                  , 'category'      : 'folder'
                                  }
                                , { 'id'            : 'edit'
                                  , 'name'          : 'Edit'
                                  , 'action'        : 'forum_edit_form'
                                  , 'permissions'   : (ManageProperties,)
                                  , 'category'      : 'folder'
                                  }
                                , { 'id'            : 'localroles'
                                  , 'name'          : 'Local Roles'
                                  , 'action'        : 'folder_localrole_form'
                                  , 'permissions'   : (ManageProperties,)
                                  , 'category'      : 'folder'
                                  }
                                , { 'id'            : 'forum_post_message'
                                  , 'name'          : 'Post Message'
                                  , 'action'        : 'forum_post_message'
                                  , 'permissions'   : (AddPortalContent, )
                                  , 'category'      : 'folder'
                                  }
                                , { 'id'            : 'metadata'
                                  , 'name'          : 'Metadata'
                                  , 'action'        : 'cwip_metadata_edit_form'
                                  , 'permissions'   : (ModifyPortalContent, )
                                  }
                                )
                             }
                           


-- 
Karl Anderson      kra@monkey.org           http://www.monkey.org/~kra/