Skip to content

Commit

Permalink
Cleaned up text_filters.py, so that now standard filters (those inclu…
Browse files Browse the repository at this point in the history
…ded 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.)
  • Loading branch information
lethain committed Jul 9, 2008
1 parent f718e70 commit b25dcd4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion text_filters.py
Expand Up @@ -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
Expand All @@ -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,)

0 comments on commit b25dcd4

Please sign in to comment.