Hello,
I'm currently developping an application used to serve
content in
different format through HTTP.
I decided to use a Tool that will run at the
'before_finalize' point,
that will take a look at the Accept header and then will
serialize the
body obtained from the cherrypy controller to the requested
format.
I guess you can see me coming into a bug.
In fact this simple piece of code won't work:
class Root:
_cp_config = {'tools.serializer.on': True}
def a(self, thing):
return [thing]
a.exposed = True
def b(self, thing):
return thing
b.exposed = True
root = Root()
So that when serializing the output of '/a?thing=toto' to
json I should get
'["toto"]' and the output of '/b?thing=toto' to
json should return
'"toto"'. But of course this does not work.
I tracked down the reason why this does not work. It relies
in the Body
implementation in _cprequest. This implementation for
performance
reason wraps a string into a list of one element. Using the
collapse_body
method won't work either since then it's the return value of
'a' that is
wrongly set.
The solution I've found so far is to monkey patch
cherrypy.response.Body
So dear list, I was wondering does anybody here got a better
idea ?
PS: Do you have an idea when will "CherryPy
Essentials" will begin
shipping ?
--
(°> Nicolas Évrard
/ ) Liège - Belgique
^^
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|