>> * Once I got response.status_code working, it started shoving my HTML
>> response into the middle of a big error template instead of just serving
>> what I had. This totally messed with my Web service which counts on
>> the sparse HTML error messages I provide. I hacked around the problem.
>> In my action, I wrote:
>>
>> request.environ['error_response_is_intentional'] = True
>>
>> In error.py's document method, I wrote:
>>
>> resp = request.environ['pylons.original_response']
>> if request.environ.get('error_response_is_intentional', False):
>> page = resp.body
>> else:
>> content = literal(resp.body) or
>> cgi.escape(request.GET.get('message', ''))
>> page = error_document_template % \
>> dict(prefix=request.environ.get('SCRIPT_NAME', ''),
>> code=cgi.escape(request.GET.get('code',
>> str(resp.status_int))),
>> message=content)
>> return pag
>>
>> This is definitely a hack. I'm not even sure why this behavior changed.
>> If I set request.status_code, and I set the HTML containing the error
>> message, it should just leave it alone.
>
> One of the default middlewares is doing this--StatusCodeRedirect. I
> completely removed this from the Pylons project I'm using for web
> services.
>
> In another project, I have this in certain controllers:
>
> request.environ['pylons.status_code_redirect'] = True
>
> I found that by reading the source. If I understand it correctly, it
> disables StatusCodeRedirect for a given request. (It seems to work,
> but the semantics are confusing.)
Yep, that worked like a charm, thanks!
Since this is a change in behavior and it requires a change in code to
get the old behavior back, it probably makes sense to call this out in
the upgrading docs.
Thanks Again,
-jj
--
In this life we cannot do great things. We can only do small things
with great love. -- Mother Teresa
http://jjinux.blogspot.com/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---