Changes between Version 66 and Version 67 of XmlRpcPlugin


Ignore:
Timestamp:
Sep 3, 2008, 12:21:53 AM (16 years ago)
Author:
niklas.cathor@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • XmlRpcPlugin

    v66 v67  
    171171         
    172172See [/attachment/wiki/XmlRpcPlugin/trac_xml_rpc_example_java.zip?format=raw this example zip file]
    173          
     173
     174=== Using from Ruby ===
     175You can either use the XMLRPC functionality included in the [http://ruby-doc.org/stdlib/libdoc/xmlrpc/rdoc/index.html Ruby Standard Library] or [/attachment/wiki/XmlRpcPlugin/trac4r.tar.gz download the trac4r library] which does all the trivial stuff for you.
     176
     177This example uses trac4r:
     178{{{
     179#!ruby
     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 = Trac.new "https://dev.example.com/trac/my_awesome_project", "myusername", "mypassword"
     183# get a list of all tickets (as an array of numbers)
     184trac.tickets.list :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
     188trac.tickets.get_all :include_closed => true
     189# get a single ticket
     190ticket = trac.tickets.get 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
     199trac.wiki.list
     200# download one page
     201trac.wiki.get_html "SomeRandomPageName" # HTML version
     202trac.wiki.get_raw "AnotherRandomPageName" # trac syntax version (e.g. for editing)
     203# for previews use
     204trac.wiki.raw_to_html "content of a page in [wiki:WikiFormatting Trac syntax] as a ''String''"
     205# to post a page use
     206trac.wiki.put "NameOfThePage", "content in Trac syntax"
     207# list the attachments of a wiki page
     208trac.wiki.attachments "NameOfThePage"
     209# save an attachment
     210File.new("my_cool_document","w") do |f|
     211  f.write trac.wiki.get_attachment "NameOfThePage", "my_cool_document.pdf"
     212end
     213}}}
     214
     215Also see the included Documentation in trac4r/doc
     216
     217If you need to do a custom query do
     218{{{
     219#!ruby
     220trac.query("system.getAPIVersion")
     221}}}
     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 ;)
     224
     225If you have any problems with trac4r you can email me: niklas.cathor (eat) gmail dot com
     226
    174227=== API Usage ===
    175228