Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
plone.app.contentrules.actions.copy.CopyActionExecutor Class Reference

List of all members.

Public Member Functions

def __init__
def __call__
def error
def generate_id

Public Attributes

 context
 element
 event

Detailed Description

The executor for this action.

Definition at line 55 of file copy.py.


Constructor & Destructor Documentation

def plone.app.contentrules.actions.copy.CopyActionExecutor.__init__ (   self,
  context,
  element,
  event 
)

Definition at line 61 of file copy.py.

00061 
00062     def __init__(self, context, element, event):
00063         self.context = context
00064         self.element = element
00065         self.event = event

Here is the caller graph for this function:


Member Function Documentation

Definition at line 66 of file copy.py.

00066 
00067     def __call__(self):
00068         portal_url = getToolByName(self.context, 'portal_url', None)
00069         if portal_url is None:
00070             return False
00071         
00072         obj = self.event.object
00073         
00074         path = self.element.target_folder
00075         if len(path) > 1 and path[0] == '/':
00076             path = path[1:]
00077         target = portal_url.getPortalObject().unrestrictedTraverse(str(path), None)
00078     
00079         if target is None:
00080             self.error(obj, _(u"Target folder ${target} does not exist.", mapping={'target' : path}))
00081             return False
00082 
00083         try:
00084             obj._notifyOfCopyTo(target, op=0)
00085         except ConflictError:
00086             raise
00087         except Exception, e:
00088             self.error(obj, str(e))
00089             return False
00090             
00091         old_id = obj.getId()
00092         new_id = self.generate_id(target, old_id)
00093         
00094         orig_obj = obj
00095         obj = obj._getCopy(target)
00096         obj._setId(new_id)
00097         
00098         notify(ObjectCopiedEvent(obj, orig_obj))
00099 
00100         target._setObject(new_id, obj)
00101         obj = target._getOb(new_id)
00102         obj.wl_clearLocks()
00103 
00104         obj._postCopy(target, op=0)
00105 
00106         OFS.subscribers.compatibilityCall('manage_afterClone', obj, obj)
00107         
00108         notify(ObjectClonedEvent(obj))
00109         
00110         return True 
        

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 111 of file copy.py.

00111 
00112     def error(self, obj, error):
00113         request = getattr(self.context, 'REQUEST', None)
00114         if request is not None:
00115             title = utils.pretty_title_or_id(obj, obj)
00116             message = _(u"Unable to copy ${name} as part of content rule 'copy' action: ${error}",
00117                           mapping={'name' : title, 'error' : error})
00118             IStatusMessage(request).addStatusMessage(message, type="error")
            

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 119 of file copy.py.

00119 
00120     def generate_id(self, target, old_id):
00121         taken = getattr(target, 'has_key', None)
00122         if taken is None:
00123             item_ids = set(target.objectIds())
00124             taken = lambda x: x in item_ids
00125         if not taken(old_id):
00126             return old_id
00127         idx = 1
00128         while taken("%s.%d" % (old_id, idx)):
00129             idx += 1
00130         return "%s.%d" % (old_id, idx)
        

Here is the caller graph for this function:


Member Data Documentation

Definition at line 62 of file copy.py.

Definition at line 63 of file copy.py.

Definition at line 64 of file copy.py.


The documentation for this class was generated from the following file: