z4r / python-rtkit

Python Api for Request Tracker's REST interface
http://z4r.github.com/python-rtkit/
Other
68 stars 44 forks source link

Support for multiline text in comment #12

Closed Tojaj closed 12 years ago

Tojaj commented 12 years ago

From official RT wiki [1] about REST interface: "If your comment contains multiple lines, each new line must be preceded by a space (e.g. "line 1\n line 2")."

This patch introduce logic which do the thing. In case that the 'Text' field in an user request contains multiline string, a space is prepended to every line (except the first line).

Usage of the library remains the same: params = { 'content' :{ 'Action' : 'comment', 'Text' : 'Comment\nwith\nseveral\nlines', }, } response = resource.post(path='ticket/16/comment', payload=params,)

Benefit: User can add comments with multiple lines without need of own text pre-processing (adding a space before each line of text).

[1] http://requesttracker.wikia.com/wiki/REST