From: <umg...@us...> - 2007-06-25 11:36:23
|
Revision: 453 http://svn.sourceforge.net/pybridge/?rev=453&view=rev Author: umgangee Date: 2007-06-25 04:36:23 -0700 (Mon, 25 Jun 2007) Log Message: ----------- Fix SQLObject sqlite connection string for win32 systems. Modified Paths: -------------- trunk/pybridge/pybridge/server/database.py Modified: trunk/pybridge/pybridge/server/database.py =================================================================== --- trunk/pybridge/pybridge/server/database.py 2007-06-25 10:16:56 UTC (rev 452) +++ trunk/pybridge/pybridge/server/database.py 2007-06-25 11:36:23 UTC (rev 453) @@ -35,10 +35,17 @@ engine = config['Database'].get('Engine', 'sqlite') # Default to SQLite. if engine == 'sqlite': - dbfile = config['Database'].get('DatabaseName', + dbpath = config['Database'].get('DatabaseName', env.find_config_server('pybridge-server.db')) - connection_string = "sqlite://" + dbfile + # SQLObject uses a special syntax to specify path on Windows systems. + # This code block is from http://simpleweb.essienitaessien.com/example + if(dbpath[1] == ':'): + s = re.sub('\\\\', '/', dbpath) # Change '\' to '/' + s = re.sub(':', '|', s, 1) # Special for sqlite + dbpath = '/' + s + connection_string = "sqlite://" + dbpath + else: username = config['Database'].get('Username', '') password = config['Database'].get('Password', '') @@ -60,7 +67,7 @@ connection_string += '/' + dbname try: - connection = connectionForURI(connection_string) # TODO: fix for Win32. + connection = connectionForURI(connection_string) log.msg("Connection to %s database succeeded" % engine) except Exception, e: log.err(e) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |