[Zope3-checkins] CVS: Zope3/src/zope/app - copy.py:1.1 configure.zcml:1.7

Sidnei da Silva sidnei@x3ng.com.br
Mon, 3 Feb 2003 12:11:27 -0500


Update of /cvs-repository/Zope3/src/zope/app
In directory cvs.zope.org:/tmp/cvs-serv32461/src/zope/app

Modified Files:
	configure.zcml 
Added Files:
	copy.py 
Log Message:
Adapters for IObjectMover and IObjectCopier

=== Added File Zope3/src/zope/app/copy.py ===
from zope.app.interfaces.copy import IObjectMover
from zope.app.interfaces.copy import IObjectCopier

class ObjectMover:
    '''Use getAdapter(obj, IObjectMover) to move an object somewhere.'''

    __implements__ = IObjectMover

    def moveTo(target, name=None):
        '''Move this object to the target given.
        
        Returns the new name within the target
        Typically, the target is adapted to IPasteTarget.'''

        object = self.context
        if target.acceptsObject(object):
            return target.pasteObject(object, name)
        
    def moveable():
        '''Returns True if the object is moveable, otherwise False.'''
        return True

    def moveableTo(target, name=None):
        '''Say whether the object can be moved to the given target.

        Returns True if it can be moved there. Otherwise, returns
        false.
        '''
        return True
    
class ObjectCopier:

    __implements__ = IObjectCopier

    def copyTo(target, name=None):
        """Copy this object to the target given.

        Returns the new name within the target, or None
        if the target doesn't do names.
        Typically, the target is adapted to IPasteTarget.
        After the copy is added to the target container, publish
        an IObjectCopied event in the context of the target container.
        If a new object is created as part of the copying process, then
        an IObjectCreated event should be published.
        """
        object = self.context
        if target.acceptsObject(object):
            return target.pasteObject(object, name)

    def copyable():
        '''Returns True if the object is copyable, otherwise False.'''
        return True

    def copyableTo(target, name=None):
        '''Say whether the object can be copied to the given target.
        
        Returns True if it can be copied there. Otherwise, returns
        False.
        '''
        return True


=== Zope3/src/zope/app/configure.zcml 1.6 => 1.7 ===
--- Zope3/src/zope/app/configure.zcml:1.6	Mon Feb  3 10:08:28 2003
+++ Zope3/src/zope/app/configure.zcml	Mon Feb  3 12:10:55 2003
@@ -44,12 +44,6 @@
       provides="zope.app.interfaces.annotation.IAnnotations"
       for="zope.app.interfaces.annotation.IAttributeAnnotatable" />
 
-
-  <adapter
-      factory="zope.app.introspector.Introspector"
-      permission="zope.View"
-      provides="zope.app.interfaces.introspector.IIntrospector" />
-
   <adapter
       factory="zope.app.dependable.Dependable"
       provides="zope.app.interfaces.dependable.IDependable"
@@ -59,6 +53,16 @@
       factory="zope.app.size.DefaultSized"
       provides="zope.app.interfaces.size.ISized"
       permission="zope.View" />
+
+  <adapter
+      factory="zope.app.copy.ObjectMover"
+      provides="zope.app.interfaces.copy.IObjectMover"
+      for="*" />
+
+  <adapter
+      factory="zope.app.copy.ObjectCopier"
+      provides="zope.app.interfaces.copy.IObjectCopier"
+      for="*" />
 
   <include package="zope.app.container" />
   <include package="zope.app.content" />