Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/atoidejouer/db/story.py
diff options
context:
space:
mode:
Diffstat (limited to 'atoidejouer/db/story.py')
-rw-r--r--atoidejouer/db/story.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/atoidejouer/db/story.py b/atoidejouer/db/story.py
index 515be85..d10cd87 100644
--- a/atoidejouer/db/story.py
+++ b/atoidejouer/db/story.py
@@ -169,7 +169,6 @@ class Key(object):
"%s='%s'" % ("title", self.title),
"%s='%s'" % ("mime_type", self.mime_type),
"%s='%s'" % ("timestamp", self.timestamp),
- "%s=%s" % ("layer", self.layer),
"%s%s%s" % ("time", sign, time),
]),
order)
@@ -232,10 +231,12 @@ class Key(object):
DB().update(key)
# update previous
end = self.time
- _do_fresh(DB()._all(query=self._query_duration(end, sign='<', order='-')))
+ _do_fresh(DB()._all(
+ query=self._query_duration(end, sign='<', order='-')))
# update next
start = self.time + self.duration
- _do_fresh(DB()._all(query=self._query_duration(start, sign='>', order='-')))
+ _do_fresh(DB()._all(
+ query=self._query_duration(start, sign='>', order='-')))
def _del(self, refresh=True):
# list next keys
@@ -272,17 +273,19 @@ class Key(object):
class DB(object):
- class __Singleton:
+ class __Singleton(object):
- def __init__(self, config=None, name="story", obj=Key):
+ 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)
+ detect_types=sqlite3.PARSE_DECLTYPES,
+ check_same_thread=False)
self.con.row_factory = sqlite3.Row
- self.__check()
+ if create is True:
+ self.__create()
- def __check(self):
+ def __create(self):
cur = self.con.cursor()
# remove all first
try:
@@ -356,13 +359,13 @@ class DB(object):
# singleton instance
instance = None
- def __new__(c, force=False):
+ def __new__(c, force=False, create=False):
"""Singleton new init.
"""
# if doesn't already initialized
if not DB.instance\
or force is True:
# create a new instance
- DB.instance = DB.__Singleton()
+ DB.instance = DB.__Singleton(create=create)
# return the manager object
return DB.instance