Hi Alexandre,

I've done something like this in my controller:

 def __call__(self, environ, start_response):
        # Wrap an exception in an XMLRPC fault
        try:
            return XMLRPCController.__call__(self, environ, start_response)
        except:
            logException()
            if asbool(config['global_conf']['debug']):
                return xmlrpc_fault(0,
traceback.format_exc())(environ, start_response)
            else:
                return xmlrpc_fault(0, "An internal server error
occurred")(environ, start_response)
        finally:
            Session.remove()

Note the call to the return value of xmlrpc_fault with (environ, start_response)

HTH,

Chris


On Feb 4, 2008 5:53 AM, Alexandre Conrad <[EMAIL PROTECTED]> wrote:
>
> I'd like to put this post back up, hoping for a reply...
>
>
>
> Alexandre Conrad wrote:
>
> > Hi,
> >
> > I would like to know how errors should be handled having webservices
> > running with XMLRPCController.
> >
> > Say I have a "def login(self, user, password)" method. If the login
> > fails, how should I return the errors to the client? I saw, from the
> > following docs:
> >
> >    http://wiki.pylonshq.com/display/pylonsdocs/Using+the+XMLRPCController
> >
> > that a convenient fault handler function is provided:
> >
> > def xmlrpc_fault(code, message):
> >      """Convenience method to return a Pylons response XMLRPC Fault"""
> >
> > So I imported this function in my controller:
> >
> > from pylons.controllers.xmlrpc import xmlrpc_fault
> >
> > and added to my login method:
> >
> > user = model.User.query.filter_by(user=user, password=password).one()
> > if not user:
> >      return xmlrpc_fault(LOGIN_ERR, "incorrect login")
> >
> > Is this how it should be handled ? If it is, I have the following error
> > message:
> >
> > exceptions.TypeError: cannot marshal <class
> > 'paste.wsgiwrappers.WSGIResponse'> objects
> >
> > Regards,
>
> --
> Alexandre CONRAD
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to