comparison roundup/backends/__init__.py @ 3084:b286373a517f

fix exception in have_backend('tsearch2')
author Alexander Smishlajev <a1s@users.sourceforge.net>
date Thu, 06 Jan 2005 17:57:05 +0000
parents 4fcb61bfe4ec
children 4aeb0d0cf0d6
comparison
equal deleted inserted replaced
3083:b9a819ef7554 3084:b286373a517f
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: __init__.py,v 1.33 2004-11-29 07:34:39 anthonybaxter Exp $ 18 # $Id: __init__.py,v 1.34 2005-01-06 17:57:05 a1s Exp $
19 19
20 '''Container for the hyperdb storage backend implementations. 20 '''Container for the hyperdb storage backend implementations.
21 ''' 21 '''
22 __docformat__ = 'restructuredtext' 22 __docformat__ = 'restructuredtext'
23 23
28 # module name, have_backend quietly returns False. 28 # module name, have_backend quietly returns False.
29 # Otherwise the error is reraised. 29 # Otherwise the error is reraised.
30 _modules = { 30 _modules = {
31 'mysql': 'MySQLdb', 31 'mysql': 'MySQLdb',
32 'postgresql': 'psycopg', 32 'postgresql': 'psycopg',
33 'tsearch2': 'psycopg',
33 } 34 }
34 35
35 def get_backend(name): 36 def get_backend(name):
36 '''Get a specific backend by name.''' 37 '''Get a specific backend by name.'''
37 vars = globals() 38 vars = globals()
41 # import the backend module 42 # import the backend module
42 module_name = 'back_%s' % name 43 module_name = 'back_%s' % name
43 try: 44 try:
44 module = __import__(module_name, vars) 45 module = __import__(module_name, vars)
45 except: 46 except:
46 # import failed, but in versions prior to 2.4, a (broken) 47 # import failed, but in versions prior to 2.4, a (broken)
47 # module is left in sys.modules and package globals; 48 # module is left in sys.modules and package globals;
48 # subsequent imports would succeed and get the broken module. 49 # subsequent imports would succeed and get the broken module.
49 # This no longer happens in Python 2.4 and later. 50 # This no longer happens in Python 2.4 and later.
50 if sys.version_info < (2, 4): 51 if sys.version_info < (2, 4):
51 del sys.modules['.'.join((__name__, module_name))] 52 del sys.modules['.'.join((__name__, module_name))]

Roundup Issue Tracker: http://roundup-tracker.org/