TurboGears / tg2

Python web framework with full-stack layer implemented on top of a microframework core with support for SQL DBMS, MongoDB and Pluggable Applications
http://www.turbogears.org/
Other
806 stars 78 forks source link

Templating support for flash #32

Closed moschlar closed 10 years ago

moschlar commented 12 years ago

I really would like to be able to customize the looks of the flash element, and I think using "real" templates would be the best approach (think ToscaWidgets style).

I would try to wrap it around the current implementation using WebFlash so that it needs to be actively activated and configured in app_config but would otherwise be non-disruptive to the current implementation.

Are there any objections if I were to implement it and make a pull request? I.e. would you consider merging it, if it's done properly, or can I spend my time more useful? :smile:

amol- commented 12 years ago

I think it's a good feature, but not one that should involve too much changes, we should try to avoid adding something too complex for a feature that the user can implement by himself in a bunch of lines of code.

the tg.flash.TGFlash class can probably be modified to use a template instead of plain string substitution and also make possible to pass a dictionary as the message instead of a string. Would that be a good enough solution? In that case we can probably manage to make something that is fully backward compatible but also makes possible to render templates inside the flash.

moschlar commented 11 years ago

I'm playing around here: https://github.com/moschlar/tgext.flash

amol- commented 11 years ago

The workshop branch has a different implementation that doesn't rely anymore on webflash and supports python3, if you want to experiment there we can easily merge a proposed patch that keeps backward compatibility.

https://github.com/TurboGears/tg2/blob/workshop/tg/flash.py

moschlar commented 11 years ago

Should be TG>=2.3 compatible in https://github.com/moschlar/tgext.flash/tree/38887b6b084c3e10cd58283c4d071c9941162ab3 I only use imports which are present in <2.3 and >=2.3 .

Maybe we can merge it after some more refinements, I'll tell the mailing list about it, maybe someone has ideas ;).

I'd like to keep it available as an extension so it is usable for <2.3, too!

amol- commented 10 years ago

This is something which looks great to have but is missing some core features. Can we extend tgext.flash with the missing JS support (which is foundamental when used with caching) or should we provide a custom implementation in TurboGears itself?

moschlar commented 10 years ago

See also #52

amol- commented 10 years ago

Solved by https://github.com/TurboGears/tg2/commit/07fc5e254f02235e1661e6fbb8aec8d58085adbc documented at http://turbogears.readthedocs.org/en/development/turbogears/webflash.html#flash-options

moschlar commented 10 years ago

:+1: