Skip to content

Commit 7f56eef

Browse files
committed
xmlrpc: logging; content property
The 'content' property is special: It should not be set to None when receiving an empty string (creation of an empty file) but to an empty string instead. Otherwise we'll get a traceback from the backend.
1 parent 10bdbb7 commit 7f56eef

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,8 @@ Fixed:
504504
commits to otk handling) even when a Reject exception occurs. The fix
505505
implements separate database connections for otk/session handling and
506506
normal database operation.
507+
- Allow empty content property for file and message via xmlrpc
508+
interface. This used to raise a traceback in the (sql) backend.
507509

508510

509511
2016-01-11: 1.5.1

roundup/xmlrpc.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
# For license terms see the file COPYING.txt.
55
#
66

7+
import logging
78
from roundup import hyperdb
89
from roundup.exceptions import Unauthorised, UsageError
910
from roundup.date import Date, Range, Interval
1011
from roundup import actions
1112
from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
1213
from xmlrpclib import Binary
14+
from traceback import format_exc
1315

1416
def translate(value):
1517
"""Translate value to becomes valid for XMLRPC transmission."""
@@ -52,7 +54,11 @@ def props_from_args(db, cl, args, itemid=None):
5254
except hyperdb.HyperdbValueError as message:
5355
raise UsageError, message
5456
else:
55-
props[key] = None
57+
# If we're syncing a file the contents may not be None
58+
if key == 'content':
59+
props[key] = ''
60+
else:
61+
props[key] = None
5662

5763
return props
5864

@@ -147,7 +153,11 @@ def create(self, classname, *args):
147153
result = cl.create(**props)
148154
self.db.commit()
149155
except (TypeError, IndexError, ValueError) as message:
150-
raise UsageError, message
156+
# The exception we get may be a real error, log the traceback if we're debugging
157+
logger = logging.getLogger('roundup.xmlrpc')
158+
for l in format_exc().split('\n'):
159+
logger.debug(l)
160+
raise UsageError (message)
151161
return result
152162

153163
def set(self, designator, *args):
@@ -164,7 +174,11 @@ def set(self, designator, *args):
164174
result = cl.set(itemid, **props)
165175
self.db.commit()
166176
except (TypeError, IndexError, ValueError) as message:
167-
raise UsageError, message
177+
# The exception we get may be a real error, log the traceback if we're debugging
178+
logger = logging.getLogger('roundup.xmlrpc')
179+
for l in format_exc().split('\n'):
180+
logger.debug(l)
181+
raise UsageError (message)
168182
return result
169183

170184

0 commit comments

Comments
 (0)