comparison MoinMoin/util/pysupport.py @ 51:54d5932d5a03

merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action Patches applied: * arch@arch.thinkmo.de--2003-archives/moin--main--1.3--patch-930 fix error handling in plugins, fix broken chart action * nirs@freeshell.org--2005/moin--fix--1.3--patch-50 merge from main * nirs@freeshell.org--2005/moin--fix--1.3--patch-51 fix error handling in plugins * nirs@freeshell.org--2005/moin--fix--1.3--patch-52 merge from main * nirs@freeshell.org--2005/moin--fix--1.3--patch-53 update changes with chart action fix imported from: moin--main--1.5--patch-52
author Nir Soffer <nirs@freeshell.org>
date Thu, 29 Sep 2005 00:36:27 +0000
parents 77665d8e2254
children ca35d9e6d63e
comparison
equal deleted inserted replaced
50:69dfbae549ac 51:54d5932d5a03
55 def importName(modulename, name): 55 def importName(modulename, name):
56 """ Import name dynamically from module 56 """ Import name dynamically from module
57 57
58 Used to do dynamic import of modules and names that you know their 58 Used to do dynamic import of modules and names that you know their
59 names only in runtime. 59 names only in runtime.
60
61 Any error raised here must be handled by the caller.
60 62
61 @param modulename: full qualified mudule name, e.g. x.y.z 63 @param modulename: full qualified mudule name, e.g. x.y.z
62 @param name: name to import from modulename 64 @param name: name to import from modulename
63 @rtype: any object 65 @rtype: any object
64 @return: name from module or None if there is no such name 66 @return: name from module
65 """ 67 """
66 try: 68 module = __import__(modulename, globals(), {}, [name])
67 module = __import__(modulename, globals(), {}, [name]) 69 return getattr(module, name)
68 return getattr(module, name, None)
69 except ImportError:
70 return None
71 70
72 71
73 def makeThreadSafe(function, lock=None): 72 def makeThreadSafe(function, lock=None):
74 """ Call with a function you want to make thread safe 73 """ Call with a function you want to make thread safe
75 74