Changes between Version 66 and Version 67 of XmlRpcPlugin

Sep 3, 2008 2:21:53 AM (6 years ago)
niklas.cathor (eat) gmail dot com



  • XmlRpcPlugin

    v66 v67  
    172172See [/attachment/wiki/XmlRpcPlugin/ this example zip file]  
     174=== Using from Ruby === 
     175You can either use the XMLRPC functionality included in the [ Ruby Standard Library] or [/attachment/wiki/XmlRpcPlugin/trac4r.tar.gz download the trac4r library] which does all the trivial stuff for you. 
     177This example uses trac4r: 
     180require 'trac4r/trac' 
     181# initialize the connection (username and password can be ommitted if not needed, but most of the time you will need them if anonymous doesn't have XMLRPC permissions) 
     182trac = "", "myusername", "mypassword" 
     183# get a list of all tickets (as an array of numbers) :include_closed => true # this is the default anyway 
     185# get all the tickets 
     186# NOTE: the results here are cached, so you can call it as often as you want without producing traffic more than once. 
     187# use ":cached_results => false" to get the latest version :include_closed => true 
     189# get a single ticket 
     190ticket = 5 
     191# print the data 
     192puts "Title: #{ticket.summary}" 
     193puts "Description: #{ticket.description}" 
     194puts "Milestone: #{ticket.milestone}" 
     195puts "Status: #{ticket.status}" 
     196puts "Type: #{ticket.type}" 
     197puts "Priority: #{ticket.priority}" 
     198# get a list of all wiki pages 
     200# download one page "SomeRandomPageName" # HTML version "AnotherRandomPageName" # trac syntax version (e.g. for editing) 
     203# for previews use "content of a page in [wiki:WikiFormatting Trac syntax] as a ''String''" 
     205# to post a page use "NameOfThePage", "content in Trac syntax" 
     207# list the attachments of a wiki page "NameOfThePage" 
     209# save an attachment"my_cool_document","w") do |f| 
     211  f.write "NameOfThePage", "my_cool_document.pdf" 
     215Also see the included Documentation in trac4r/doc 
     217If you need to do a custom query do 
     222The first argument is the method name, all other arguments are directly passed to XMLRPC. 
     223For this example of cause you could do `trac.api_version` instead ;) 
     225If you have any problems with trac4r you can email me: niklas.cathor (eat) gmail dot com 
    174227=== API Usage ===