Issue10 Editing

TitleaddLibrary is commented out since it will break on default Plone
Prioritywish Statuschatting
Superseder Nosy Listgotcha, jw
Assigned Togotcha TopicsVideoLibrary

Created on 2004-09-07.09:48:39 by jw, last changed 2004-09-07.10:32:58.

Messages
msg15 Author: jw Date: 2004-09-07.10:12:09 remove
CMFPlone/Portal.py

    # Override CMFCore's invokeFactory to return the id
returned by the
    # factory in case the factory modifies the id
   
security.declareProtected(CMFCorePermissions.AddPortalContent,
'invokeFactory')
    def invokeFactory( self
                     , type_name
                     , id
                     , RESPONSE=None
                     , *args
                     , **kw
                     ):
        '''Invokes the portal_types tool.'''
        pt = getToolByName( self, 'portal_types' )
        myType = pt.getTypeInfo(self)

        if myType is not None:
            if not myType.allowType( type_name ):
                raise ValueError, 'Disallowed subobject
type: %s' % type_name

        args = (type_name, self, id, RESPONSE) + args
        new_id = pt.constructContent(*args, **kw)
        if new_id is None or new_id == '':
            new_id = id
        return new_id
msg14 Author: jw Date: 2004-09-07.10:11:28 remove
CMFPlone/TypesTool.py:

    security.declarePublic('constructContent')
    def constructContent( self
                        , type_name
                        , container
                        , id
                        , RESPONSE=None
                        , *args
                        , **kw
                        ):
        """
            Build an instance of the appropriate content
class in
            'container', using 'id'.
        """
        info = self.getTypeInfo( type_name )
        if info is None:
            raise 'ValueError', 'No such content type: %s' %
type_name

        # check we're allowed to access the type object
        if not self._checkViewType(info):
            raise Unauthorized,info

        ob = apply(info.constructInstance, (container, id) +
args, kw)

        if RESPONSE is not None:
            immediate_url = '%s/%s' % ( ob.absolute_url()
                                      , info.immediate_view )
            RESPONSE.redirect( immediate_url )
        # THIS IS THE IMPORTANT PART:
        return ob.getId()
msg13 Author: jw Date: 2004-09-07.09:52:42 remove
correction:

CMFCore/TypesTool constructContent does not return the id of
the newly created object, where CMFPlone/PloneFolder
invokeFactory expects it to.

CMFPlone/Portal does not have an invokeFactory defined, but
should (we think).
msg12 Author: jw Date: 2004-09-07.09:48:39 remove
We want to provide a custom addLibrary factory for the
Library object, to be able to control the id of it.
Apparently this triggers a bug in CMFCore/TypesTool and
CMFPlone/Portal where the invokeFactory does not return the
id of the newly created object as it should.

When this has been fixed in Plone we can enable it again,
for now we rely on the *convention* of using 'videolibrary'
for the id.
History
Date User Action Args
2004-09-07 10:32:58gotchasetpriority: feature
2004-09-07 10:12:12jwsetassignedto: (no value)
2004-09-07 10:12:09jwsetmessages: + msg15
2004-09-07 10:11:29jwsetmessages: + msg14
2004-09-07 09:52:42jwsetstatus: unread
messages: + msg13
2004-09-07 09:48:40jwcreate