[Zope-CMF] Re: WorkflowMethod wrapper for Event/edit breaks XMLRPC

Tres Seaver tseaver at zope.com
Sat Aug 14 12:03:42 EDT 2004


Joel Burton wrote:
> While trying to write an XMLRPC script that creates and edits both News 
> and Event types, I tripped across a piece of the broken WorkflowMethod 
> machinery.
> 
> Event.edit() is workflow-method wrapped. NewsItems.edit() is not.
> News items are editable via XMLRPC, Events are not. 
> ZPublisher/mapply.py, in mapply, checks for and uses func_code for the 
> function called. Since Event.edit is wrapped, and doesn't expose it's 
> func_code (it's on the ._m attribute, which is the actual method), 
> mapply raises an exception that func_code can't be found.
> 
> (I believe there were similar problems with WebDAV not playing well
> with WorkflowMethods)
> 
> There seem to be a few possibilities:
> 
> 1. Have the few pieces in CMFDefault that wrap edit have alternate,
>    unwrapped edit functions. Then these could be called from XMLRPC.
> 
> 2. Put a check in mapply that, if it can import WorkflowMethod, and
>    object is of the class WorkflowMethod, uses the real method in _m.
> 
> 3. Expose func_code in wrapped methods (not sure if this is feasible).
> 
> 4. Remove the wrapping of edit on things in CMFDefault/CMFCalendar.
> 
> I don't run the server I'm trying to execute XMLRPC on (actually, it's 
> zope.org and plone.org!) so #1 seems unlikely, and a bad fix anyway.
> #2-4 seem better options.
> 
> Is anyone using WorkflowMethods on CMFDefault stuff? They're 
> inconsistently applied, so it seems unlikely that they're widely used.
> 
> Any advice on how to proceed would be appreciated.

We should rip out WorkflowMethod altogether;  it wires policy (when to 
trigger workflow transitions) into mechanism:  for instance, what if you 
have a "review" workflow which needs to record / react to the fact that 
a given user has *viewed* a document?

A better way to achieve the same goals would be to add an event service, 
and change the default POST-handler skin methods to publish an 
IContentChanged event (perhaps we publish events from within view 
templatse, too?)

The Events code is already under ZPL, and in heavy production use:

   http://cvs.zope.org/Products/Event/

Maybe we should move that code into CMF 1.6.  In the meantime, stripping 
out WorkflowMethod is an obvious bit of cleanup.

As a workaround for your current use case, I would recommend using a 
skin method, rather than the "native" 'edit' method.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com



More information about the Zope-CMF mailing list