From b25dcd45655040bf82024d6321fce26307d4e3e9 Mon Sep 17 00:00:00 2001 From: Will Larson Date: Wed, 9 Jul 2008 12:37:02 +0900 Subject: [PATCH] Cleaned up text_filters.py, so that now standard filters (those included within text_filters.py) can be designated within the settings.py by string name (for example 'comment_markdown' or 'entry_markdown' to avoid the need for additional imports.) --- text_filters.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/text_filters.py b/text_filters.py index 661c19e..08b6ab0 100644 --- a/text_filters.py +++ b/text_filters.py @@ -27,9 +27,15 @@ from lifeflow.markdown import mdx_foreign_formats +def convert_string(str): + if LOCALS.has_key(str): + return LOCALS[str] + else: + return str def comment_markup(txt,obj=None): filters = getattr(settings,'LIFEFLOW_COMMENT_FILTERS', DEFAULT_COMMENT_FILTERS) + filters = [convert_string(filter) for filter in filters] for filter in filters: txt = filter(txt) return txt @@ -52,6 +58,6 @@ def entry_markdown(txt,obj=None): md = Markdown(txt,extensions=exts,extension_configs={'lifeflow':obj}) return md.convert() - +LOCALS = locals() DEFAULT_COMMENT_FILTERS = (comment_markdown,) DEFAULT_ENTRY_FILTERS = (entry_markdown,)