From: Eric A. <er...@ab...> - 2008-09-26 06:39:53
|
I'm using Markdown with Django, not as a template filter but by running database text through markdown as it is saved, so that the markdown text is saved into one field, and HTML converted text is saved into another field. I want different behavior for different models, so I instantiate two Markdown objects, one for filtering blog entry text (safe_mode is off) and one for filtering comment text (safe_mode is set to 'remove'). Both are instantiated at the top of a single models.py module, like this: safe_md = Markdown() remove_md = Markdown(safe_mode='remove') What I've found is that the second instance seems to override the first. Blog text run through safe_md.convert() has its HTML removed, as though its safe_mode were set to 'remove'. I "fixed" the problem by commenting out the second instance, and later I moved it inside a function where it's hidden. This isn't at all how I expected this to work, and I wonder if it's a bug with Markdown or with my expectations. I thought it might have had to do with Django, perhaps threading or something, but it behaves the same way in the Python interpreter. Can someone explain what's going on here? TIA, Eric |