From acb4b6642e50c901bd498daa5bd48bd910550457 Mon Sep 17 00:00:00 2001 From: florent Date: Thu, 19 Jan 2012 01:05:56 +0000 Subject: ensure good start --- diff --git a/atoidejouer/db/story.py b/atoidejouer/db/story.py index 426baa1..6496bff 100644 --- a/atoidejouer/db/story.py +++ b/atoidejouer/db/story.py @@ -1,5 +1,5 @@ # python import -import copy, logging +import copy, logging, os # get application logger logger = logging.getLogger('atoidejouer') @@ -278,12 +278,17 @@ class DB(object): def __init__(self, create=False, name="story", obj=Key): self.name, self.obj = name, obj db_path = storage.get_db_path('default') - self.con = sqlite3.connect(db_path, - detect_types=sqlite3.PARSE_DECLTYPES, - check_same_thread=False) - self.con.row_factory = sqlite3.Row - if create is True: - self.__create() + # DEBUG + logger.debug('[db.story] init - db_path: %s' % db_path) + if os.path.exists(os.path.dirname(db_path)): + # DEBUG + logger.debug('[db.story] init - dirname found!') + self.con = sqlite3.connect(db_path, + detect_types=sqlite3.PARSE_DECLTYPES, + check_same_thread=False) + self.con.row_factory = sqlite3.Row + if create is True: + self.__create() def __create(self): cur = self.con.cursor() @@ -323,7 +328,6 @@ class DB(object): cur = self.con.cursor() # DEBUG # logger.debug('[db.story] get - query: %s' % obj.select()) - # DEBUG cur.execute(obj.select()) for obj in self._fetch(cur): yield obj -- cgit v0.9.1