Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
b1d10231
Commit
b1d10231
authored
Aug 14, 2002
by
Sidnei da Silva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Collector #61
parent
a322c99f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
2 deletions
+88
-2
doc/CHANGES.txt
doc/CHANGES.txt
+4
-0
lib/python/OFS/CopySupport.py
lib/python/OFS/CopySupport.py
+7
-2
lib/python/OFS/tests/testCopySupport.py
lib/python/OFS/tests/testCopySupport.py
+77
-0
No files found.
doc/CHANGES.txt
View file @
b1d10231
...
@@ -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
...
...
lib/python/OFS/CopySupport.py
View file @
b1d10231
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
##############################################################################
##############################################################################
__doc__
=
"""Copy interface"""
__doc__
=
"""Copy interface"""
__version__
=
'$Revision: 1.8
0
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.8
1
$'
[
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
())
...
...
lib/python/OFS/tests/testCopySupport.py
View file @
b1d10231
...
@@ -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
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment