z4r/python-rtkit — pull request #12 by Tojaj (2012-10-15 08:04:19+00:00)
Title: Support for multiline text in comment

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