You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by Graham Dumpleton <gr...@dscpl.com.au> on 2005/12/09 02:20:31 UTC

Re: [jira] Created: (MODPYTHON-97) mod_python.publisher iterablesand content_type broken

Jim Gallacher wrote ..
> Gregory (Grisha) Trubetskoy wrote:
> > 
> > On Thu, 8 Dec 2005, Graham Dumpleton (JIRA) wrote:
> > 
> >> In 3.2, mod_python.publisher was modified so that if it encountered
> an 
> >> interable it would recursively iterate over the items and publish each
> >> with the result being concatenated.
> > 
> > 
> > I didn't know this either. I'm curious what the rational for this was
> - 
> > I'm not sure whether this is good or bad. If I have an object which it
> > iterable, but also has its own idea of how to represent itself as a 
> > string as a whole, isn't this going to be slightly unexpected?
> > 
> > Grisha
> 
> I believe this is the source of this change:
> http://issues.apache.org/jira/browse/MODPYTHON-15

One can see I wasn't entirely happy back then when I saw that the
initial idea had been proposed. At that point I was expecting it to only
apply to generators, but the way it was implemented meant that doing
something as simple as returning an array of strings would trigger the
new behaviour.

I only found this when I later did:

  def index():
    return sys.version_info[:3]

I was expecting to get back in the browser:

  (2, 3, 0)

but was seeing:

  230

This confused me for some time before I realised what was going on. I
grumbled a bit more on one of the mailing lists at the time. :-(

Personally I find the idea of recursive decent of iterable structures to
construct a response interesting and have been playing with the idea a
bit in my head lately and it was from that I realised this problem
existed with the content type. Rather than obscure the issue of the
content type problem at the moment, I'll leave a discussion to how
the concept might be used to advantage another time. Most importantly
though, I'll say again, I really don't think it should be applied automagically,
the user should make the decision of when it is applied, else you get
unexpected things like that above with the version info.

Graham