Commit b1d10231 authored by Sidnei da Silva's avatar Sidnei da Silva

Fixed Collector #61

parent a322c99f
...@@ -144,6 +144,10 @@ Zope Changes ...@@ -144,6 +144,10 @@ Zope Changes
- Collector #516 -- "title" property on image tags - Collector #516 -- "title" property on image tags
- Collector #61 -- now manage_PasteObjects return a list of dictionaries
containing {'id':original_id,'new_id':newly_pasted_obj_id} when called
with REQUEST=None
Zope 2.6.0 alpha 1 Zope 2.6.0 alpha 1
Features Added Features Added
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
############################################################################## ##############################################################################
__doc__="""Copy interface""" __doc__="""Copy interface"""
__version__='$Revision: 1.80 $'[11:-2] __version__='$Revision: 1.81 $'[11:-2]
import sys, Globals, Moniker, tempfile, ExtensionClass import sys, Globals, Moniker, tempfile, ExtensionClass
from marshal import loads, dumps from marshal import loads, dumps
...@@ -137,6 +137,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -137,6 +137,7 @@ class CopyContainer(ExtensionClass.Base):
oblist=[] oblist=[]
op=cp[0] op=cp[0]
app = self.getPhysicalRoot() app = self.getPhysicalRoot()
result = []
for mdata in cp[1]: for mdata in cp[1]:
m = Moniker.loadMoniker(mdata) m = Moniker.loadMoniker(mdata)
...@@ -156,7 +157,9 @@ class CopyContainer(ExtensionClass.Base): ...@@ -156,7 +157,9 @@ class CopyContainer(ExtensionClass.Base):
message=sys.exc_info()[1], message=sys.exc_info()[1],
action ='manage_main') action ='manage_main')
ob=ob._getCopy(self) ob=ob._getCopy(self)
orig_id=ob.getId()
id=self._get_id(ob.getId()) id=self._get_id(ob.getId())
result.append({'id':orig_id, 'new_id':id})
ob._setId(id) ob._setId(id)
self._setObject(id, ob) self._setObject(id, ob)
ob = self._getOb(id) ob = self._getOb(id)
...@@ -186,7 +189,9 @@ class CopyContainer(ExtensionClass.Base): ...@@ -186,7 +189,9 @@ class CopyContainer(ExtensionClass.Base):
aq_parent(aq_inner(ob))._delObject(id) aq_parent(aq_inner(ob))._delObject(id)
ob = aq_base(ob) ob = aq_base(ob)
orig_id=id
id=self._get_id(id) id=self._get_id(id)
result.append({'id':orig_id, 'new_id':id })
ob._setId(id) ob._setId(id)
self._setObject(id, ob, set_owner=0) self._setObject(id, ob, set_owner=0)
...@@ -202,7 +207,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -202,7 +207,7 @@ class CopyContainer(ExtensionClass.Base):
REQUEST['__cp'] = None REQUEST['__cp'] = None
return self.manage_main(self, REQUEST, update_menu=1, return self.manage_main(self, REQUEST, update_menu=1,
cb_dataValid=0) cb_dataValid=0)
return '' return result
manage_renameForm=Globals.DTMLFile('dtml/renameForm', globals()) manage_renameForm=Globals.DTMLFile('dtml/renameForm', globals())
......
...@@ -143,6 +143,83 @@ class TestCopySupport( unittest.TestCase ): ...@@ -143,6 +143,83 @@ class TestCopySupport( unittest.TestCase ):
self.failUnless('newfile' in self.folder1.objectIds()) self.failUnless('newfile' in self.folder1.objectIds())
self.failUnless('newfile' in self.folder2.objectIds()) self.failUnless('newfile' in self.folder2.objectIds())
def testPasteSingleNotSameID( self ):
self.failUnless( 'file' in self.folder1.objectIds() )
self.failIf( 'file' in self.folder2.objectIds() )
cookie = self.folder1.manage_copyObjects( ids=('file',) )
result = self.folder2.manage_pasteObjects( cookie )
self.failUnless( 'file' in self.folder1.objectIds() )
self.failUnless( 'file' in self.folder2.objectIds() )
self.failUnless( result == [{'id':'file', 'new_id':'file'}])
def testPasteSingleSameID( self ):
self.failUnless( 'file' in self.folder1.objectIds() )
self.failIf( 'file' in self.folder2.objectIds() )
manage_addFile(self.folder2, 'file',
file='', content_type='text/plain')
cookie = self.folder1.manage_copyObjects( ids=('file',) )
result = self.folder2.manage_pasteObjects( cookie )
self.failUnless( 'file' in self.folder1.objectIds() )
self.failUnless( 'file' in self.folder2.objectIds() )
self.failUnless( 'copy_of_file' in self.folder2.objectIds() )
self.failUnless( result == [{'id':'file', 'new_id':'copy_of_file'}])
def testPasteMultiNotSameID( self ):
self.failUnless( 'file' in self.folder1.objectIds() )
self.failIf( 'file1' in self.folder2.objectIds() )
manage_addFile(self.folder1, 'file1',
file='', content_type='text/plain')
self.failIf( 'file2' in self.folder2.objectIds() )
manage_addFile(self.folder1, 'file2',
file='', content_type='text/plain')
self.failIf( 'file' in self.folder2.objectIds() )
self.failIf( 'file1' in self.folder2.objectIds() )
self.failIf( 'file2' in self.folder2.objectIds() )
cookie = self.folder1.manage_copyObjects( ids=('file','file1','file2',) )
result = self.folder2.manage_pasteObjects( cookie )
self.failUnless( 'file' in self.folder1.objectIds() )
self.failUnless( 'file1' in self.folder1.objectIds() )
self.failUnless( 'file2' in self.folder1.objectIds() )
self.failUnless( 'file' in self.folder2.objectIds() )
self.failUnless( 'file1' in self.folder2.objectIds() )
self.failUnless( 'file2' in self.folder2.objectIds() )
self.failUnless( result == [{'id':'file', 'new_id':'file'},
{'id':'file1', 'new_id':'file1'},
{'id':'file2', 'new_id':'file2'}])
def testPasteMultiSameID( self ):
self.failUnless( 'file' in self.folder1.objectIds() )
self.failIf( 'file1' in self.folder2.objectIds() )
manage_addFile(self.folder1, 'file1',
file='', content_type='text/plain')
self.failIf( 'file2' in self.folder2.objectIds() )
manage_addFile(self.folder1, 'file2',
file='', content_type='text/plain')
self.failIf( 'file' in self.folder2.objectIds() )
manage_addFile(self.folder2, 'file',
file='', content_type='text/plain')
self.failIf( 'file1' in self.folder2.objectIds() )
manage_addFile(self.folder2, 'file1',
file='', content_type='text/plain')
self.failIf( 'file2' in self.folder2.objectIds() )
manage_addFile(self.folder2, 'file2',
file='', content_type='text/plain')
cookie = self.folder1.manage_copyObjects( ids=('file','file1','file2',) )
result = self.folder2.manage_pasteObjects( cookie )
self.failUnless( 'file' in self.folder1.objectIds() )
self.failUnless( 'file1' in self.folder1.objectIds() )
self.failUnless( 'file2' in self.folder1.objectIds() )
self.failUnless( 'file' in self.folder2.objectIds() )
self.failUnless( 'file1' in self.folder2.objectIds() )
self.failUnless( 'file2' in self.folder2.objectIds() )
self.failUnless( 'copy_of_file' in self.folder2.objectIds() )
self.failUnless( 'copy_of_file1' in self.folder2.objectIds() )
self.failUnless( 'copy_of_file2' in self.folder2.objectIds() )
self.failUnless( result == [{'id':'file', 'new_id':'copy_of_file'},
{'id':'file1', 'new_id':'copy_of_file1'},
{'id':'file2', 'new_id':'copy_of_file2'}])
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( TestCopySupport ) ) suite.addTest( unittest.makeSuite( TestCopySupport ) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment