Serialize lists

This overrides the RequestHandler.write and RequestHandler.write_error methods to support serializing of lists and to allow error messages in our format to be written via self.write_error().

This means that this:

        except InvalidInputFormat, e:

            self.set_status(e.http_status)
            self.write({'error_message': e.error_message, 'error_code' : e.error_code})

        except ReceiverGusNotFound, e:

            self.set_status(e.http_status)
            self.write({'error_message': e.error_message, 'error_code' : e.error_code})

        except ContextGusNotFound, e:

            self.set_status(e.http_status)
            self.write({'error_message': e.error_message, 'error_code' : e.error_code})

        except KeyError, e: # Until validateMessage is not restored, it's needed.

            self.set_status(511)
            self.write({'error_message': "temporary error: %s" % e, 'error_code' : 123})

can become:

        except (ReceiverGusNotFound, InvalidInputFormat, ContextGusNotFound) as error:
            self.write_error(error)

        except KeyError, e: # Until validateMessage is not restored, it's needed.

            self.set_status(511)
            self.write({'error_message': "temporary error: %s" % e, 'error_code' : 123})

This reduces boiler plating (i.e. code duplication).