Skip to content

Commit 4e6f682

Browse files
author
Richard Jones
committed
allow binary data for "content" props through rawToHyperdb
1 parent 0164eca commit 4e6f682

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Fixed:
2020
- Session API and cleanup thanks anatoly t.
2121
- Make WSGI handler threadsafe (sf #1968027)
2222
- Improved URL matching RE (sf #2038858)
23+
- Allow binary file content submission via XML-RPC (sf #1995623)
2324

2425

2526
2008-03-01 1.4.4

roundup/hyperdb.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: hyperdb.py,v 1.131 2007-09-27 06:18:53 jpend Exp $
18+
# $Id: hyperdb.py,v 1.132 2008-08-18 06:21:53 richard Exp $
1919

2020
"""Hyperdatabase implementation, especially field types.
2121
"""
@@ -53,8 +53,12 @@ class String(_Type):
5353
def __init__(self, indexme='no', required=False):
5454
super(String, self).__init__(required)
5555
self.indexme = indexme == 'yes'
56-
def from_raw(self, value, **kw):
56+
def from_raw(self, value, propname='', **kw):
5757
"""fix the CRLF/CR -> LF stuff"""
58+
if propname == 'content':
59+
# Why oh why wasn't the FileClass content property a File
60+
# type from the beginning?
61+
return value
5862
return fixNewlines(value)
5963
def sort_repr (self, cls, val, name):
6064
if not val:

test/test_xmlrpc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ def testCreate(self):
6969
results = self.server.display('joe', 'random', issueid, 'title')
7070
self.assertEqual(results['title'], 'foo')
7171

72+
def testFileCreate(self):
73+
results = self.server.create('joe', 'random', 'file', 'content=hello\r\nthere')
74+
fileid = 'file' + results
75+
results = self.server.display('joe', 'random', fileid, 'content')
76+
self.assertEqual(results['content'], 'hello\r\nthere')
77+
7278
def testAuthUnknown(self):
7379
# Unknown user (caught in XMLRPC frontend).
7480
self.assertRaises(Unauthorised, self.server.list,

0 commit comments

Comments
 (0)