Ben Bangert wrote:
> On Jul 2, 12:22 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> 
>> 1. unknown links didn't dispatch to 'default' method
>> 2. pylons 'c', 'g' params need to be returned implicitly (return
>> dict(c=c, g=g))
>> 3. need implement tg_flash
> 
> I've looked into implementing this as well. I'm not sure what the
> reason was for calling it tg_flash (surely its obvious its from tg if
> you just import it there?), but I'd like to have a flash function as
> well. It should also ensure the cookie is signed properly (I'm not
> sure the tg one does this right now?). I was thinking of having it
> work in a more similar model to Rails, such that you could just do:
> flash['login_msg'] = "Welcome to the login!"
> 
> And have multiple flashes keyed at once.

That seems weird to me... what purpose does the key have?  Just so you 
can clear the key with "flash['login_msg'] = None" ?

It to me that it should be something like response.flash('message').  I 
think currently there may be some problems with returning WSGI 
applications, and then everything in response is lost; but I think this 
should be fixed generally anyway.  Probably with a middleware just 
outside of the HTTPException middleware.  Maybe something that looks like:

class PylonsResponseFixup(object):
     def __init__(self, app):
         self.app = app
     def __call__(self, environ, start_response):
         environ['pylons.response_folded_in'] = False
         def repl_start_response(status, headers, exc_info=None):
             if not environ['pylons.response_folded_in']:
                 pylons.response.fold_in_headers(headers)
             return start_response(status, headers)
         return self.app(environ, repl_start_response)

class WSGIResponse:
     ...
     def fold_in_headers(self, headers):
         my_headers = self.wsgi_response()[1]
         for name, value in my_headers:
             if name.lower() == 'set-cookie':
                 headers.append((name, value))

And when you actually get a WSGIResponse object in the PylonsController, 
just set environ['pylons.response_folded_in'] to True so that the 
middleware doesn't futz with it anymore.


-- 
Ian Bicking | [EMAIL PROTECTED] | http://blog.ianbicking.org
             | Write code, do good | http://topp.openplans.org/careers

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" 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/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to