On Jan 19, 11:59 pm, [email protected] wrote:
> Hi
>
> I am using XmlRpcPlugin to download, modify, and update tickets
> (specifically our custom field 'reviewno'). The API for
> ticket.update() says:
>  "'New-style' call requires two additional items in attributes: (1)
> 'action' for workflow support (including any supporting fields as
> retrieved by getActions()), (2) '_ts' changetime token for detecting
> update collisions (as received from get() or update() calls). Calling
> update without 'action' and '_ts' changetime token is deprecated, and
> will raise errors in a future version."
>
> So what is supposed to go in the action entry. If I have it there but
> blank, I get back
>
>       xmlrpc.client.Fault: <Fault 1: "'Rpc: Ticket 52 by admin invalid
> action ''' while executing 'ticket.update()'">
>
> and when I don't put it in at all it works. My guess to why this works
> is because the error raising has not yet been enabled. However, I
> would like my program to still work when the API is updated. At the
> moment I am stripping out everything from attributes except reviewno,
> and _ts at the moment so that any accidental changes to other fields
> are not uploaded.
>
> Also, should I be updating _ts when I upload the ticket, or is just
> using the value that came down with the ticket ok? Currently I use the
> value that came down with Trac, and that seems to work, but it's not
> clear if I am being told to use use the value I got from ticket.get(),
> or if I should generate a new one at upload time with the same format.
>
> Thanks
> Scott

Hi Scott,

The 'action' attribute is a consequence of the TracWorkflow way of
making any updates, and just like making any ticket updates via web
the RPC will (soon) enforce the use of an 'action' to accompany the
update. Go ahead and open any ticket via web, and notice the radio
selection does not allow 'None' as an option - you have to make a
selection, even if it is the usually available 'leave' to just leave
the status as it is.

Due to TracWorkflow, you cannot know what possible actions are
available across a range of tickets - you need to request the
available actions for each one, and you will get a result based on the
current status and settings of the ticket just now. If you make a
change of any kind, your workflow may provide you with a different set
of action options / states the next time you need to update.

Again, the Trac ticket web form is a good visualization. An action
like 'leave' when available is simple. But workflow also allows for
more complex constructs through workflow controllers. So for instance
the 'reassign' action requires another field to be present too: You
need to also include a field describing who it should be reassigned
to.

All this information is available through ticket.getActions(<ticket-
id>) - you get back a structure with each action, and for each action
you get a list of additional fields required when selecting the state,
and if the field is a select/dropdown field you also get all the
various options available to select from - like with restrict_owner
option that enables a dropdown for "reassign to:" via web.

The plugin includes a functional test suite (making live calls over
the (loopback) wire), and should be quite helpful in describing how
things work. You may want to have a look at the ticket tests:

http://trac-hacks.org/browser/xmlrpcplugin/trunk/tracrpc/tests/ticket.py

Plugins may add further actions, so none of this can be defined in the
RPC interface - it must all be requested, and the exact options all
depend on the current state of the ticket - and who you are, and what
your permissions are.

The tests should likely also describe the '_ts' field used to detect
mid-air collisions. You use the _ts you downloaded when fetching the
latest ticket data, and you include it when posting it back to the
server so that you are not allowed to post new comments or changes
when there are newer changes made on the server. No doubt you have
also seen such a warning via web if someone has updated the ticket
since you loaded the web page but before you finished typing and hit
'submit'. The ticket 'last modified' and your 'timestamp' ('_ts')
needs to be the same.

Enjoy!


:::simon

https://www.coderesort.com
http://trac-hacks.org/wiki/osimons

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-users?hl=en.

Reply via email to