diff options
author | Waylan Limberg <waylan@gmail.com> | 2008-12-08 20:05:39 -0500 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2008-12-08 20:05:39 -0500 |
commit | 358decd3b74591b2a2ccee55279f2b7c44312422 (patch) | |
tree | 662801138ec90121d8d7ea80aecadc310b3ad010 | |
parent | c1f4bc166fc6e95dbdf1c21a32cf6c89e7e8baf1 (diff) | |
download | markdown-358decd3b74591b2a2ccee55279f2b7c44312422.tar.gz markdown-358decd3b74591b2a2ccee55279f2b7c44312422.tar.bz2 markdown-358decd3b74591b2a2ccee55279f2b7c44312422.zip |
A few more tweaks to extension loading. We don't test trying to load non-existant or broken extensions often enough. This should handle things better.
-rw-r--r-- | markdown/__init__.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/markdown/__init__.py b/markdown/__init__.py index 8a473b1..44cb25e 100644 --- a/markdown/__init__.py +++ b/markdown/__init__.py @@ -283,15 +283,12 @@ class Markdown: for ext in extensions: if isinstance(ext, basestring): ext = load_extension(ext, configs.get(ext, [])) - elif hasattr(ext, 'extendMarkdown'): - # Looks like an Extension. - # Nothing to do here. - pass - else: + try: + ext.extendMarkdown(self, globals()) + except AttributeError: message(ERROR, "Incorrect type! Extension '%s' is " "neither a string or an Extension." %(repr(ext))) - continue - ext.extendMarkdown(self, globals()) + def registerExtension(self, extension): """ This gets called by the extension """ @@ -461,7 +458,7 @@ def load_extension(ext_name, configs = []): module_name_old_style = '_'.join(['mdx', ext_name]) # Try loading the extention first from one place, then another - try: # New style (markdown_extensons.<extension>) + try: # New style (markdown.extensons.<extension>) module = __import__(module_name_new_style, {}, {}, [ext_module]) except ImportError: try: # Old style (mdx.<extension>) @@ -474,7 +471,7 @@ def load_extension(ext_name, configs = []): # function called makeExtension() try: return module.makeExtension(configs.items()) - except: + except AttributeError: message(CRITICAL, "Failed to instantiate extension '%s'" % ext_name) |