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:Esbachb@tycoelectronics.com]
Sent: lundi 4 septembre 2006 10:24
To: xwiki-users@objectweb.org
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:Esbachb@tycoelectronics.com]
Sent: 01 September 2006 10:31
To: xwiki-users@objectweb.org
Subject: RE: [xwiki-users] "Clone" another documents objects when creating a new document

That seems to do it perfectly, thanks!


From: BOUSQUET Jeremie [mailto:Jeremie.BOUSQUET@gemalto.com]
Sent: 01 September 2006 09:45
To: xwiki-users@objectweb.org
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
Jeremie.Bousquet@gemalto.com
www.gemalto.com



From: Esbach, Brandon [mailto:Esbachb@tycoelectronics.com]
Sent: vendredi 25 août 2006 12:58
To: xwiki-users@objectweb.org
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