Version 0.9.840 has a known bug on copying attachments. This is fixed in version 0.9.1252 or SVN In general the recent SVN version have many improvements in this area. In particuler there are new document APIs allowing to work on newer document by clonning them. There is also a rename function in the API Finally you might not need all this (provided that you don't have attachments in your template), if you use the "?template=" parameter to create a new document. If you edit a document and pass ?template=Templates.MyTemplate then the content of Templates.MyTemplate will be copied into the newly edited document. Ludovic BOUSQUET Jeremie a écrit :
I just tested on my side, I have the same problem than you, the attachments copy fails. In fact it seems that attachments creation in the new page fails. (I only tested once)
I'm certain that I could have it work during my first tests of page copy. I don't have time to test again, but I think sometimes it works, sometimes it doesn't ...
In my case the attached files are listed in the copied page, but if you click on one you get an exception. And I can't delete the page at all for the same reason (database exception, a row cannot be found in the attachments table).
By the way I had some problems with attachments, apart of pages copy, but with the same exceptions returned, and in a random fashion ...
------------------------------------------------------------------------ *From:* Esbach, Brandon [mailto:[email protected]] *Sent:* lundi 4 septembre 2006 10:24 *To:* [email protected] *Subject:* RE: [xwiki-users] "Clone" another documents objects when creating a new document
Attachments don't seem to copy with this method - I get a wrapped exception error: The size of the attachment is around 20k. Comments are fine, as are other objects (at least the one's I've tried). ------------------------------------------------------------------------ *From:* Esbach, Brandon [mailto:[email protected]] *Sent:* 01 September 2006 10:31 *To:* [email protected] *Subject:* RE: [xwiki-users] "Clone" another documents objects when creating a new document
That seems to do it perfectly, thanks!
------------------------------------------------------------------------ *From:* BOUSQUET Jeremie [mailto:[email protected]] *Sent:* 01 September 2006 09:45 *To:* [email protected] *Subject:* RE: [xwiki-users] "Clone" another documents objects when creating a new document
Hello,
I believe you can use the copyDocument() method. I use it to rename pages, I copy a document to a newly named document, then delete the old one. All objects and attachments are also copied in the process, so that may interest you (as far as all objects are included in the template document I believe)
$xwiki.copyDocument($sourceDoc, $targetDoc)
*Jeremie, Bousquet GSE Solution CMO Gemalto *Tel: +33 4 42 36 42 93 Avenue du Jujubier, Z.I Athelia IV 13705 La Ciotat, FRANCE *[email protected]* www.gemalto.com <http://www.gemalto.com/>
------------------------------------------------------------------------ *From:* Esbach, Brandon [mailto:[email protected]] *Sent:* vendredi 25 août 2006 12:58 *To:* [email protected] *Subject:* [xwiki-users] "Clone" another documents objects when creating a new document
Hi All,
Is there any way to clone all objects in an existing document to a different document with one server request? So that a template document can be maintained with default object values; and can be brought in painlessly to a new document.
/Brandon Esbach/ /Software Engineer/ /M/A-Com Eurotec Operations/ /LoughMahon Technology Park,/ /Skehard Road,/ /Blackrock,/ /Cork, Ireland/ /Tel +353 21 4808305/
-- Ludovic Dubost XPertNet: http://www.xpertnet.fr/ Blog: http://www.ludovic.org/blog/ XWiki: http://www.xwiki.com Skype: ldubost AIM: nvludo Yahoo: ludovic