Skip to content

Commit 243806e

Browse files
author
Richard Jones
committed
*** empty log message ***
1 parent 19305b3 commit 243806e

File tree

7 files changed

+81
-32
lines changed

7 files changed

+81
-32
lines changed

CHANGES.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ Feature:
1313
- all RDBMS backends now have indexes on several columns
1414
- change nosymessage and send_message to accept msgid=None (RFE #707235).
1515
- handle Resent-From: headers (sf bug 841151)
16-
- existing trackers (ie. live ones) may be used as templates for new
17-
trackers - the TEMPLATE-INFO.txt name entry has the tracker's dir name
18-
appended (so the demo tracker's template name is "classic-demo")
1916
- always sort MultilinkHTMLProperty in the correct order, usually
2017
alphabetically (sf feature 790512).
2118
- added script for copying user(s) from tracker to tracker (sf patch
@@ -74,8 +71,16 @@ Cleanup:
7471
* form_parser.py - parsePropsFromForm & extractFormList in a FormParser class
7572

7673

77-
2004-??-?? 0.6.7
74+
2004-??-?? 0.6.8
75+
Fixed:
76+
- existing trackers (ie. live ones) may be used as templates for new
77+
trackers - the TEMPLATE-INFO.txt name entry has the tracker's dir name
78+
appended (so the demo tracker's template name is "classic-demo")
79+
80+
81+
2004-03-01 0.6.7
7882
Fixed:
83+
- be more backward-compatible when asking for EMAIL_CHARSET
7984
- made error on create consistent with edit when user enters invalid data
8085
for Multilink and Link form fields (sf bug 904072)
8186
- made errors from bad input in the quick "Show issue:" form more

roundup/backends/back_mysql.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def sql_open_connection(self):
6868
self.sql("SET AUTOCOMMIT=0")
6969
self.sql("BEGIN")
7070
try:
71-
self.database_schema = self.load_dbschema()
71+
self.load_dbschema()
7272
except MySQLdb.OperationalError, message:
7373
if message[0] != ER.NO_DB_ERROR:
7474
raise
@@ -82,7 +82,16 @@ def sql_open_connection(self):
8282
# http://www.mysql.com/doc/en/CREATE_TABLE.html
8383
self.sql("CREATE TABLE ids (name varchar(255), num INT) TYPE=%s"%
8484
self.mysql_backend)
85-
self.sql("CREATE INDEX ids_name_idx on ids(name)")
85+
self.sql("CREATE INDEX ids_name_idx ON ids(name)")
86+
self.create_version_2_tables()
87+
88+
def create_version_2_tables(self):
89+
self.cursor.execute('CREATE TABLE otks (key VARCHAR(255), '
90+
'value VARCHAR(255), __time FLOAT(20))')
91+
self.cursor.execute('CREATE INDEX otks_key_idx ON otks(key)')
92+
self.cursor.execute('CREATE TABLE sessions (key VARCHAR(255), '
93+
'last_use FLOAT(20), user VARCHAR(255))')
94+
self.cursor.execute('CREATE INDEX sessions_key_idx ON sessions(key)')
8695

8796
def __repr__(self):
8897
return '<myroundsql 0x%x>'%id(self)
@@ -104,13 +113,6 @@ def save_dbschema(self, schema):
104113
s = repr(self.database_schema)
105114
self.sql('INSERT INTO schema VALUES (%s)', (s,))
106115

107-
def load_dbschema(self):
108-
self.cursor.execute('SELECT schema FROM schema')
109-
schema = self.cursor.fetchone()
110-
if schema:
111-
return eval(schema[0])
112-
return None
113-
114116
def save_journal(self, classname, cols, nodeid, journaldate,
115117
journaltag, action, params):
116118
params = repr(params)

roundup/backends/back_postgresql.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,22 @@ def sql_open_connection(self):
2727
self.cursor = self.conn.cursor()
2828

2929
try:
30-
self.database_schema = self.load_dbschema()
30+
self.load_dbschema()
3131
except:
3232
self.rollback()
3333
self.database_schema = {}
3434
self.sql("CREATE TABLE schema (schema TEXT)")
3535
self.sql("CREATE TABLE ids (name VARCHAR(255), num INT4)")
36+
self.sql("CREATE INDEX ids_name_idx ON ids(name)")
37+
self.create_version_2_tables()
38+
39+
def create_version_2_tables(self):
40+
self.cursor.execute('CREATE TABLE otks (key VARCHAR(255), '
41+
'value VARCHAR(255), __time NUMERIC)')
42+
self.cursor.execute('CREATE INDEX otks_key_idx ON otks(key)')
43+
self.cursor.execute('CREATE TABLE sessions (key VARCHAR(255), '
44+
'last_use NUMERIC, user VARCHAR(255))')
45+
self.cursor.execute('CREATE INDEX sessions_key_idx ON sessions(key)')
3646

3747
def __repr__(self):
3848
return '<roundpsycopgsql 0x%x>' % id(self)

roundup/backends/back_sqlite.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_sqlite.py,v 1.13 2004-02-11 23:55:09 richard Exp $
1+
# $Id: back_sqlite.py,v 1.14 2004-03-05 00:08:09 richard Exp $
22
'''Implements a backend for SQLite.
33
44
See https://pysqlite.sourceforge.net/ for pysqlite info
@@ -30,14 +30,23 @@ def sql_open_connection(self):
3030
self.conn = sqlite.connect(db=db)
3131
self.cursor = self.conn.cursor()
3232
try:
33-
self.database_schema = self.load_dbschema()
33+
self.load_dbschema()
3434
except sqlite.DatabaseError, error:
3535
if str(error) != 'no such table: schema':
3636
raise
3737
self.database_schema = {}
3838
self.cursor.execute('create table schema (schema varchar)')
3939
self.cursor.execute('create table ids (name varchar, num integer)')
4040
self.cursor.execute('create index ids_name_idx on ids(name)')
41+
self.create_version_2_tables()
42+
43+
def create_version_2_tables(self):
44+
self.cursor.execute('create table otks (key varchar, '
45+
'value varchar, __time varchar)')
46+
self.cursor.execute('create index otks_key_idx on otks(key)')
47+
self.cursor.execute('create table sessions (key varchar, '
48+
'last_use varchar, user varchar)')
49+
self.cursor.execute('create index sessions_key_idx on sessions(key)')
4150

4251
def sql_close(self):
4352
''' Squash any error caused by us already having closed the

roundup/backends/rdbms_common.py

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.75 2004-02-11 23:55:09 richard Exp $
1+
# $Id: rdbms_common.py,v 1.76 2004-03-05 00:08:09 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -19,6 +19,12 @@
1919
probably a bit of work to be done if a database is used that actually
2020
honors column typing, since the initial databases don't (sqlite stores
2121
everything as a string.)
22+
23+
The schema of the hyperdb being mapped to the database is stored in the
24+
database itself as a repr()'ed dictionary of information about each Class
25+
that maps to a table. If that information differs from the hyperdb schema,
26+
then we update it. We also store in the schema dict a __version__ which
27+
allows us to upgrade the database schema when necessary. See upgrade_db().
2228
'''
2329
__docformat__ = 'restructuredtext'
2430

@@ -77,7 +83,9 @@ def clearCache(self):
7783
self.cache_lru = []
7884

7985
def sql_open_connection(self):
80-
''' Open a connection to the database, creating it if necessary
86+
''' Open a connection to the database, creating it if necessary.
87+
88+
Must call self.load_dbschema()
8189
'''
8290
raise NotImplemented
8391

@@ -106,24 +114,26 @@ def sql_stringquote(self, value):
106114
'''
107115
return re.sub("'", "''", str(value))
108116

117+
def load_dbschema(self):
118+
''' Load the schema definition that the database currently implements
119+
'''
120+
self.cursor.execute('select schema from schema')
121+
self.database_schema = eval(self.cursor.fetchone()[0])
122+
109123
def save_dbschema(self, schema):
110124
''' Save the schema definition that the database currently implements
111125
'''
112126
s = repr(self.database_schema)
113127
self.sql('insert into schema values (%s)', (s,))
114128

115-
def load_dbschema(self):
116-
''' Load the schema definition that the database currently implements
117-
'''
118-
self.cursor.execute('select schema from schema')
119-
return eval(self.cursor.fetchone()[0])
120-
121129
def post_init(self):
122130
''' Called once the schema initialisation has finished.
123131
124132
We should now confirm that the schema defined by our "classes"
125133
attribute actually matches the schema in the database.
126134
'''
135+
self.upgrade_db()
136+
127137
# now detect changes in the schema
128138
save = 0
129139
for classname, spec in self.classes.items():
@@ -155,6 +165,21 @@ def post_init(self):
155165
# commit
156166
self.conn.commit()
157167

168+
# update this number when we need to make changes to the SQL structure
169+
# of the backen database
170+
current_db_version = 2
171+
def upgrade_db(self):
172+
''' Update the SQL database to reflect changes in the backend code.
173+
'''
174+
version = self.database_schema.get('__version', 1)
175+
if version == 1:
176+
# version 1 doesn't have the OTK, session and indexing in the
177+
# database
178+
self.create_version_2_tables()
179+
180+
self.database_schema['__version'] = self.current_db_version
181+
182+
158183
def refresh_database(self):
159184
self.post_init()
160185

roundup/rcsv.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55

66
from roundup.i18n import _
77
from cStringIO import StringIO
8-
error = """Sorry, you need a module compatible with the csv module.
9-
Either upgrade your Python to 2.3 or later, or get and install
10-
the csv module from:
8+
error = """
9+
Sorry, you need a csv module. Either upgrade your Python to 2.3 or later,
10+
or get and install the csv module from:
1111
http://www.object-craft.com.au/projects/csv/
12-
13-
These two csv modules are different but Roundup can use either.
1412
"""
1513
try:
1614
import csv

roundup/roundupdb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: roundupdb.py,v 1.99 2004-02-29 00:35:55 richard Exp $
18+
# $Id: roundupdb.py,v 1.100 2004-03-05 00:08:09 richard Exp $
1919

2020
"""Extending hyperdb with types specific to issue-tracking.
2121
"""
@@ -149,14 +149,14 @@ def add_recipient(userid):
149149
if address:
150150
sendto.append(address)
151151
recipients.append(userid)
152-
152+
153153
def good_recipient(userid):
154154
# Make sure we don't send mail to either the anonymous
155155
# user or a user who has already seen the message.
156156
return (userid and
157157
(self.db.user.get(userid, 'username') != 'anonymous') and
158158
not seen_message.has_key(userid))
159-
159+
160160
# possibly send the message to the author, as long as they aren't
161161
# anonymous
162162
if (good_recipient(authid) and

0 commit comments

Comments
 (0)