On Wed, 2009-07-08 at 03:28 -0400, Chris McDonough wrote:
> On 7/8/09 2:54 AM, Iain Duncan wrote:
> > On Wed, 2009-07-08 at 02:36 -0400, Chris McDonough wrote:
> >> We don't have a convention for "flash".  I've been remiss in seeing how the
> >> other frameworks implement this, but I *think* something like this would 
> >> be closest:
> >>
> >> return render_template_to_response('some/template.pt', message='Updated')
> >>
> >> And in the template:
> >>
> >> <div class="someclass">${message}</div>
> >
> > Thanks Chris. The convention in the other frameworks that I've used is
> > that the message is 'flashed' when handling the update from a post, and
> > displayed after the redirect, to avoid the problem when a user hits
> > resend after a post that should not occur twice. So usually the flash
> > helper is a simple utility to set, read, and wipe a session variable or
> > cookie. I guess bfg is not making any assumptions about session vars or
> > cookies though?
> 
> Since BFG depends on no particular persistence mechanism, BFG has no built-in 
> session support, although I often use this pair of packages to get it:
> 
> http://pypi.python.org/pypi/repoze.browserid/0.1
> http://pypi.python.org/pypi/repoze.session/0.2
> 
> Of course any sessioning system would work just as well (ala Beaker).
> 
> > If you are thinking of adding such a thing to bfg, I'll hold off on my
> > own ( or use a really crappy one ).
> 
> No, I'm not.
> 
> > Can we set a simple cookie with
> > webob maybe as an ultralight version that doesn't depend on a particular
> > method of storing session vars?

At the moment I'm going for adding the message to the redirect url as a
get var, ugly but easy to scale. If anyone has other suggestions for how
to pass it on through the HTTPFound object, I'd love to hear them. I'm
pretty happy that the get var method requires no sessions or cookies
though, and it really doesn't look all that odd:

/pet/1/edit?_msg="Your+changes+have+been+saved"

I guess if I wanted to publish this app down the road as a repoze
contribution it would be best not to add any session/cookie dependencies
and just make it dead easy for others to change how flash messages are
set and consumed eh?

iain


_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to