[Zope-CVS] CVS: Packages/Moztop/idesupport/xmlrpc - folder.py:1.5
Sidnei da Silva
sidnei@x3ng.com.br
Sun, 19 Jan 2003 10:06:40 -0500
Update of /cvs-repository/Packages/Moztop/idesupport/xmlrpc
In directory cvs.zope.org:/tmp/cvs-serv25793/xmlrpc
Modified Files:
folder.py
Log Message:
First stab at a better copy-n-paste support. Will follow a interface definition & implementation in Zope3 (we didnt had copy support yet!)
=== Packages/Moztop/idesupport/xmlrpc/folder.py 1.4 => 1.5 ===
--- Packages/Moztop/idesupport/xmlrpc/folder.py:1.4 Thu Jan 16 00:03:05 2003
+++ Packages/Moztop/idesupport/xmlrpc/folder.py Sun Jan 19 10:06:38 2003
@@ -22,6 +22,7 @@
from zope.publisher.interfaces.xmlrpc import IXMLRPCPublisher
from zope.app.interfaces.dublincore import IZopeDublinCore
from zope.app.interfaces.container import IZopeContainer
+from zope.app.interfaces.traversing import IPhysicallyLocatable, ITraverser
class Methods(MethodPublisher):
""" """
@@ -47,6 +48,45 @@
container.__delitem__(old_name)
new_name = container.setObject(new_name, content)
return "Object '%s' was renamed to '%s'." %(old_name, new_name)
+
+ def copyObject(self, name):
+ """Copy object with the given name."""
+ container = getAdapter(self.context, IPhysicallyLocatable)
+ path = container.getPhysicalPath()
+
+ path = '/'.join(path)
+ if not path: path = '/'
+
+ return "Object '%s' was copied from '%s'." %(name, path)
+
+ def cutObject(self, name):
+ """Cut object with the given name."""
+ container = getAdapter(self.context, IPhysicallyLocatable)
+ path = container.getPhysicalPath()
+
+ path = '/'.join(path)
+ if not path: path = '/'
+
+ return "Object '%s' was cut from '%s'." %(name, path)
+
+ def pasteObject(self, source, operation=None):
+ """Paste object with the given name. If operation is cut,
+ remove source object."""
+ new_container = getAdapter(self.context, IZopeContainer)
+ traverser = getAdapter(self.context, ITraverser)
+ content = traverser.traverse(source)
+ content_pl = getAdapter(content, IPhysicallyLocatable)
+ content_path = content_pl.getPhysicalPath()
+ name = content_path[-1]
+ old_container_path = content_path[:-1]
+
+ if operation is not None:
+ old_container = traverser.traverse(container_path)
+ del old_container.__delitem__(name)
+
+ name = new_container.setObject(name, content)
+
+ return "Object '%s' was pasted from '%s'." %(name, old_container_path)
def deleteObject(self, name):
"""Delete object with the given name."""