Skip to content

Commit 29fc3de

Browse files
author
Richard Jones
committed
Switch to using sqlite's own locking mechanisms...
Automatically start a new transaction on hyperdb commit(). Better RDBMS demo.py nuke handling. (minor doc fixes)
1 parent a2995c7 commit 29fc3de

File tree

5 files changed

+41
-29
lines changed

5 files changed

+41
-29
lines changed

CHANGES.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@ Feature:
66
- added MD5 scheme for password hiding
77
- added support for HTTP charset selection
88
- implement __nonzero__ for HTMLProperty
9+
- remove "manual" locking of sqlite database
10+
- create a new RDBMS cursor after committing
911

10-
2004-??-?? 0.7.5
12+
13+
2004-??-?? 0.7.4
1114
Fixed:
1215
- re-acquire the OTK manager when we re-open the database
1316
- mailgw handler can close the database on us
1417

1518

16-
2004-05-28 0.7.4
17-
Fixed:
18-
- remove "manual" locking of sqlite database
19-
- create a new RDBMS cursor after committing
20-
21-
2219
2004-05-28 0.7.3
2320
Fixed:
2421
- add "checked" to truth values for Boolean input

demo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Copyright (c) 2003 Richard Jones ([email protected])
44
#
5-
# $Id: demo.py,v 1.10 2004-03-31 23:07:51 richard Exp $
5+
# $Id: demo.py,v 1.11 2004-05-28 01:09:10 richard Exp $
66

77
import sys, os, string, re, urlparse
88
import shutil, socket, errno, BaseHTTPServer
@@ -23,12 +23,14 @@ class config:
2323
MYSQL_DBPASSWORD = 'rounduptest'
2424
MYSQL_DBNAME = 'rounduptest'
2525
DATABASE = 'home'
26-
module.db_nuke(config)
26+
if module.db_exists(config):
27+
module.db_nuke(config)
2728
elif backend == 'postgresql':
2829
class config:
2930
POSTGRESQL_DATABASE = {'database': 'rounduptest'}
3031
DATABASE = 'home'
31-
module.db_nuke(config, 1)
32+
if module.db_exists(config):
33+
module.db_nuke(config)
3234

3335
init.install(home, os.path.join('templates', 'classic'))
3436
# don't have email flying around

doc/upgrading.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ Lines ``meta http-equiv`` added to the tracker templates in version 0.6.0
4444
are misleading and should be removed. Actual charset is sent in the
4545
true http header.
4646

47+
48+
Migrating from 0.7.2 to 0.7.3
49+
=============================
50+
51+
0.7.3 Configuration
52+
-------------------
53+
54+
If you choose, you may specify the directory from which static files are
55+
served (those which use the URL component ``@@file``). Currently the
56+
directory defaults to the ``TEMPLATES`` configuration variable. You may
57+
define a new variable, ``STATIC_FILES`` which overrides this value for
58+
static files.
59+
60+
4761
Migrating from 0.7.0 to 0.7.2
4862
=============================
4963

roundup/backends/back_sqlite.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_sqlite.py,v 1.28 2004-05-10 00:39:40 richard Exp $
1+
# $Id: back_sqlite.py,v 1.29 2004-05-28 01:09:11 richard Exp $
22
'''Implements a backend for SQLite.
33
44
See https://pysqlite.sourceforge.net/ for pysqlite info
@@ -50,21 +50,22 @@ class Database(rdbms_common.Database):
5050
}
5151

5252
def sql_open_connection(self):
53+
'''Open a standard, non-autocommitting connection.
54+
55+
pysqlite will automatically BEGIN TRANSACTION for us.
56+
'''
5357
db = os.path.join(self.config.DATABASE, 'db')
5458
conn = sqlite.connect(db=db)
59+
# set a 30 second timeout (extraordinarily generous) for handling
60+
# locked database
61+
conn.db.sqlite_busy_timeout(30 * 1000)
5562
cursor = conn.cursor()
5663
return (conn, cursor)
5764

5865
def open_connection(self):
5966
# ensure files are group readable and writable
6067
os.umask(0002)
6168

62-
# lock the database
63-
lockfilenm = os.path.join(self.dir, 'lock')
64-
self.lockfile = locking.acquire_lock(lockfilenm)
65-
self.lockfile.write(str(os.getpid()))
66-
self.lockfile.flush()
67-
6869
(self.conn, self.cursor) = self.sql_open_connection()
6970

7071
try:
@@ -245,17 +246,10 @@ def sql_close(self):
245246
connection.
246247
'''
247248
try:
248-
try:
249-
self.conn.close()
250-
except sqlite.ProgrammingError, value:
251-
if str(value) != 'close failed - Connection is closed.':
252-
raise
253-
finally:
254-
# always release the lock
255-
if self.lockfile is not None:
256-
locking.release_lock(self.lockfile)
257-
self.lockfile.close()
258-
self.lockfile = None
249+
self.conn.close()
250+
except sqlite.ProgrammingError, value:
251+
if str(value) != 'close failed - Connection is closed.':
252+
raise
259253

260254
def sql_rollback(self):
261255
''' Squash any error caused by us having closed the connection (and
@@ -280,6 +274,8 @@ def sql_commit(self):
280274
except sqlite.DatabaseError, error:
281275
if str(error) != 'cannot commit - no transaction is active':
282276
raise
277+
# open a new cursor for subsequent work
278+
self.cursor = self.conn.cursor()
283279

284280
def sql_index_exists(self, table_name, index_name):
285281
self.cursor.execute('pragma index_list(%s)'%table_name)

roundup/backends/rdbms_common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.102 2004-05-23 23:24:47 richard Exp $
1+
# $Id: rdbms_common.py,v 1.103 2004-05-28 01:09:11 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -1110,6 +1110,9 @@ def sql_commit(self):
11101110
print >>hyperdb.DEBUG, '+++ commit database connection +++'
11111111
self.conn.commit()
11121112

1113+
# open a new cursor for subsequent work
1114+
self.cursor = self.conn.cursor()
1115+
11131116
def commit(self):
11141117
''' Commit the current transactions.
11151118

0 commit comments

Comments
 (0)