[Zope-CMF] Permissions to add different content types

seb bacon seb@jamkit.com
Sun, 8 Jul 2001 19:10:42 +0100


* Chris Withers <chrisw@nipltd.com> [010708 18:09]:
> I hope I'm being dense. I want to make Articles and Replies (both based on
> the Document type) anonymously addable, while the rest of the content types
> only addable by members.
> 
> How can I do this? From what I've seen, everything is protected by the same
> permission: Add Portal Content so I've got a bit stuck...

AFAIK, you're right.  In Portal.py, you can find where all the Types
are added as products in a single batch (hence the way they all come
up in the products list as a single Product, CMFDefault Content).  

>From CMFDefault.__init__.py:

    utils.ContentInit( 'CMFDefault Content'
                     , content_types=contentClasses
                     , permission=ADD_CONTENT_PERMISSION
                     , extra_constructors=contentConstructors
                     , fti=CMFDefault.factory_type_information
                     ).initialize( context )

So I add other products separately, something like this:

    utils.ContentInit( 'Anon Content',
                       content_types = (anonContentClasses,),
                       permission = 'Add Anon Types',
                       extra_constructors = anonContentConstructors,
                       fti = CMFDefault.anon_factory_type_information,
                       ).initialize(context)

Which is pretty darn messy, but it gets the job done...

seb