so we did it...

        import pylons
        from pylons.controllers.util import Response
        response_options = config['pylons.response_options']
        request_counter = 1
        while request_counter <= MAX_REQUEST_TRIES:
            try:
                pylons_obj = environ['pylons.pylons']
                registry = environ['paste.registry']
                pylons_obj.response =
Response(content_type=response_options['content_type'],

charset=response_options['charset'])
                pylons_obj.response.headers.update(response_options['headers'])
                registry.register(pylons.response, pylons_obj.response)

                transaction_filter.start()
                result = WSGIController.__call__(self, environ, start_response)
                transaction_filter.commit()

                return result
            except:
                pass...


On Tue, Oct 19, 2010 at 3:25 PM, Tomasz Nazar <[email protected]> wrote:
> Hello there!
> I got this neat idea, and I'm not sure if it is supposed to work...
>
> Quick (if you're not interested in the full scenario)
> Is it possible to invoke: WSGIController.__call__(self, environ,
> start_response) many times during 1 http request to Pylons?
>
>
> A bit longer description:
> My user scenario is:
> Browser/user sends request --->
>     1* server receives and calls some Controller
>     1* WSGIController.__call__(self, environ, start_response) is
> being invoked, which..
>     1* raises some Exception (database deadlock)
>     <-- error middleware catches exception, and redirects error page
> user gets error page -->
>
> Above is normal situation. I'd like to improve it, so that server
> itself tries to handle db exception by restarting the request and
> _maybe_ next time DB will unlock tables, so that
> still-the-same-request can be processed without an error to the user.
>
> So here is what I do:
>
> Browser/user sends request --->
>     * server receives and calls some Controller
>     1* WSGIController.__call__(self, environ, start_response) is
> being invoked, which..
>     1* raises some Exception (database deadlock)
>     2* I catch the exception and run again:
> WSGIController.__call__(self, environ, start_response)
>     2* still raises some Exception (database deadlock)
>     3* I catch the exception and run again:
> WSGIController.__call__(self, environ, start_response)
>     * db is now unlocked and requests completes
>     <-- some Mako page is returned to a user
> user SHOULD gets some success page -->
>
>
> What happens is that returned value from __call__(..) is not quite
> HTML string. Rather, it's a concatenation of final HTML with the same
> HTML page with tags escaped...
> So instead of str("<html>Hello</html>")
> I get str("&lt;html&gt;Hello&lt;/html&gt;<html>Hello</html>") which is 
> wrong...
>
> Should I call sth else before calling __call__ again()
> Will it work, can it be done?
>
> Thanks for any response
>
> T.
>
>
>
> --
> _i______'simplicity_is_the_key'__________tomasz_nazar
> _ii____'i_am_concern_oriented'________________JKM-UPR
> _iii__'patsystem.sf.net'___________________linux_user
> _'aspectized.com'___________________________prevayler
>



-- 
_i______'simplicity_is_the_key'__________tomasz_nazar
_ii____'i_am_concern_oriented'________________JKM-UPR
_iii__'patsystem.sf.net'___________________linux_user
_'aspectized.com'___________________________prevayler

-- 
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