[Product-Developers] Crash while moving folder contents
Luca Fabbri
luca at keul.it
Sat Dec 3 13:43:15 UTC 2011
On Fri, Dec 2, 2011 at 6:06 PM, ajung <lists at zopyx.com> wrote:
> manage_pasteObjects() requires the result of the manage_copyObjects() call as
> parameter.
>
> -aj
As Andreas said.
This is the manage_pasteObject pydoc (you can read with DocFinderTab):
Paste previously copied objects into the current object.
If calling manage_pasteObjects from python code, pass the result
of a previous
call to manage_cutObjects or manage_copyObjects as the first argument.
Also sends IObjectCopiedEvent and IObjectClonedEvent or
IObjectWillBeMovedEvent and IObjectMovedEvent.
Also I think (please, check... I'm not sure) that if you want to use
cut/paste in the same transanction, you to put a
transaction.savepoint() between two operations.
>
> Maarten Nieber wrote
>>
>> Hi,
>>
>> I need to replace a document that has content type Section with another
>> document that has content type SectionMarketing. My approach is to simply
>> move
>> the folder contents from the old instance to the new instance, using these
>> lines:
>>
>> ids = [item.id for item in section.listFolderContents()]
>> section.manage_cutObjects(ids)
>> marketingsection.manage_pasteObjects()
>>
>> and then replace the old instance with the new instance in my tree
>> structure.
>> The call to manage_pasteObjects triggers an error: "No clipboard data
>> found."
>> (packed inside an HTML formatted error message).
>>
>> Can somebody point out what I'm doing wrong?
>> Thanks!
>> Maarten
>>
>>
>> ps My entire upgrade function is
>>
>> def upgrade_16_to_17b(setup):
>> catalog = getToolByName(setup, 'portal_catalog')
>> brains = catalog(object_provides=IMarketingContainer.__identifier__)
>>
>> for brain in brains:
>> container = brain.getObject()
>> sections = container.listFolderContents()
>> for section in sections:
>> id = section.id + '_marketing'
>> container.invokeFactory('abb.types.sectionmarketing', id,
>> title=section.title + '_marketing')
>> marketingsection = container[id]
>> ids = [item.id for item in section.listFolderContents()]
>> section.manage_cutObjects(ids)
>> marketingsection.manage_pasteObjects()
>> container.manage_delObjects(section.id)
>>
>> _______________________________________________
>> Product-Developers mailing list
>> Product-Developers at .plone
>> https://lists.plone.org/mailman/listinfo/plone-product-developers
>>
>
>
> --
> View this message in context: http://plone.293351.n2.nabble.com/Crash-while-moving-folder-contents-tp7055262p7055420.html
> Sent from the Product Developers mailing list archive at Nabble.com.
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> https://lists.plone.org/mailman/listinfo/plone-product-developers
--
-- luca
twitter: http://twitter.com/keul
linkedin: http://linkedin.com/in/lucafbb
blog: http://blog.keul.it/
More information about the Product-Developers
mailing list