Mercurial > p > roundup > code
changeset 5326:db8659c4e8eb
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.
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Tue, 29 May 2018 13:36:22 +0200 |
| parents | 7c7f3faa5e10 |
| children | 8cd518058007 |
| files | CHANGES.txt roundup/xmlrpc.py |
| diffstat | 2 files changed, 19 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Tue May 29 13:32:27 2018 +0200 +++ b/CHANGES.txt Tue May 29 13:36:22 2018 +0200 @@ -504,6 +504,8 @@ commits to otk handling) even when a Reject exception occurs. The fix implements separate database connections for otk/session handling and normal database operation. +- Allow empty content property for file and message via xmlrpc + interface. This used to raise a traceback in the (sql) backend. 2016-01-11: 1.5.1
--- a/roundup/xmlrpc.py Tue May 29 13:32:27 2018 +0200 +++ b/roundup/xmlrpc.py Tue May 29 13:36:22 2018 +0200 @@ -4,12 +4,14 @@ # For license terms see the file COPYING.txt. # +import logging from roundup import hyperdb from roundup.exceptions import Unauthorised, UsageError from roundup.date import Date, Range, Interval from roundup import actions from SimpleXMLRPCServer import SimpleXMLRPCDispatcher from xmlrpclib import Binary +from traceback import format_exc def translate(value): """Translate value to becomes valid for XMLRPC transmission.""" @@ -52,7 +54,11 @@ except hyperdb.HyperdbValueError as message: raise UsageError, message else: - props[key] = None + # If we're syncing a file the contents may not be None + if key == 'content': + props[key] = '' + else: + props[key] = None return props @@ -147,7 +153,11 @@ result = cl.create(**props) self.db.commit() except (TypeError, IndexError, ValueError) as message: - raise UsageError, message + # The exception we get may be a real error, log the traceback if we're debugging + logger = logging.getLogger('roundup.xmlrpc') + for l in format_exc().split('\n'): + logger.debug(l) + raise UsageError (message) return result def set(self, designator, *args): @@ -164,7 +174,11 @@ result = cl.set(itemid, **props) self.db.commit() except (TypeError, IndexError, ValueError) as message: - raise UsageError, message + # The exception we get may be a real error, log the traceback if we're debugging + logger = logging.getLogger('roundup.xmlrpc') + for l in format_exc().split('\n'): + logger.debug(l) + raise UsageError (message) return result
