Skip to content

Commit 1a8379e

Browse files
author
Richard Jones
committed
Fix for sqlite backend migration. Change Cookie -> SimpleCookie
1 parent 8363d82 commit 1a8379e

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

CHANGES.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ are given with the most recent entry first.
44
2004-??-?? 0.7.0b2
55
Feature:
66
- added CSV export to index pages
7-
- added new auditor, emailauditor.py, that works around a bug in IE. See
8-
emailauditor.py for more info.
7+
- added emailauditor.py which works around a bug in IE. See
8+
"detectors/emailauditor.py" for more info.
99
- added dispatcher functionality - see upgrading.txt for more info
1010
- added Reject exception which may be raised by auditors. This is trapped
1111
by mailgw and may be used to veto creation of file attachments or
@@ -15,9 +15,11 @@ Feature:
1515
Fixed:
1616
- Boolean HTML templating was broken
1717
- Link HTML templating field() was broken
18-
- Fix reporting of test inclusion in postgresql test
18+
- fix reporting of test inclusion in postgresql test
1919
- EditAction was confused about who "self" was
20-
- Edit collision detection was broken for index-page edits
20+
- edit collision detection was broken for index-page edits
21+
- sqlite backend wasn't migrating multilink tables correctly
22+
- use SimpleCookie instead of Cookie (is an alias for the evil SmartCookie)
2123

2224

2325
2004-03-24 0.7.0b1

TODO.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
This file contains items that need doing before the next release:
22

3-
- ensure index creation is triggered by the version 1->2 update
4-
(and other upgrade tests)
5-
63
Optionally:
74
- have rdbms backends look up the journal for actor if it's not set
85
- migrate to numeric ID values (fixes bug 817217)

roundup/backends/back_sqlite.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_sqlite.py,v 1.20 2004-03-22 07:45:39 richard Exp $
1+
# $Id: back_sqlite.py,v 1.21 2004-03-26 05:16:03 richard Exp $
22
'''Implements a backend for SQLite.
33
44
See https://pysqlite.sourceforge.net/ for pysqlite info
@@ -87,6 +87,8 @@ def add_actor_column(self):
8787
if tables.has_key(classname):
8888
dbspec = tables[classname]
8989
self.update_class(spec, dbspec, force=1, adding_actor=1)
90+
# we've updated - don't try again
91+
tables[classname] = spec.schema()
9092

9193
def update_class(self, spec, old_spec, force=0, adding_actor=0):
9294
''' Determine the differences between the current spec and the
@@ -106,11 +108,12 @@ def update_class(self, spec, old_spec, force=0, adding_actor=0):
106108
return 0
107109

108110
if __debug__:
109-
print >>hyperdb.DEBUG, 'update_class FIRING'
111+
print >>hyperdb.DEBUG, 'update_class FIRING for', spec.classname
110112

111113
# detect multilinks that have been removed, and drop their table
112114
old_has = {}
113-
for name,prop in old_spec[1]:
115+
for name, prop in old_spec[1]:
116+
print (name, prop)
114117
old_has[name] = 1
115118
if new_has(name) or not isinstance(prop, hyperdb.Multilink):
116119
continue
@@ -132,9 +135,31 @@ def update_class(self, spec, old_spec, force=0, adding_actor=0):
132135
for propname,x in new_spec[1]:
133136
prop = properties[propname]
134137
if isinstance(prop, hyperdb.Multilink):
135-
if force or not old_has(propname):
138+
if not old_has(propname):
136139
# we need to create the new table
137140
self.create_multilink_table(spec, propname)
141+
elif force:
142+
tn = '%s_%s'%(spec.classname, propname)
143+
# grabe the current values
144+
sql = 'select linkid, nodeid from %s'%tn
145+
if __debug__:
146+
print >>hyperdb.DEBUG, 'update_class', (self, sql)
147+
self.cursor.execute(sql)
148+
rows = self.cursor.fetchall()
149+
150+
# drop the old table
151+
self.drop_multilink_table_indexes(spec.classname, propname)
152+
sql = 'drop table %s'%tn
153+
if __debug__:
154+
print >>hyperdb.DEBUG, 'migration', (self, sql)
155+
self.cursor.execute(sql)
156+
157+
# re-create and populate the new table
158+
self.create_multilink_table(spec, propname)
159+
sql = '''insert into %s (linkid, nodeid) values
160+
(%s, %s)'''%(tn, self.arg, self.arg)
161+
for linkid, nodeid in rows:
162+
self.cursor.execute(sql, (int(linkid), int(nodeid)))
138163
elif old_has(propname):
139164
# we copy this col over from the old table
140165
fetch.append('_'+propname)
@@ -154,6 +179,8 @@ def update_class(self, spec, old_spec, force=0, adding_actor=0):
154179
self.drop_class_table_indexes(cn, old_spec[0])
155180

156181
# drop the old table
182+
if __debug__:
183+
print >>hyperdb.DEBUG, 'update_class "drop table _%s"'%cn
157184
self.cursor.execute('drop table _%s'%cn)
158185

159186
# create the new table

roundup/cgi/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.168 2004-03-25 00:44:28 richard Exp $
1+
# $Id: client.py,v 1.169 2004-03-26 05:16:03 richard Exp $
22

33
"""WWW request handler (also used in the stand-alone server).
44
"""
@@ -283,7 +283,7 @@ def determine_user(self):
283283
pass
284284

285285
# look up the user session cookie (may override the REMOTE_USER)
286-
cookie = Cookie.Cookie(self.env.get('HTTP_COOKIE', ''))
286+
cookie = Cookie.SimpleCookie(self.env.get('HTTP_COOKIE', ''))
287287
user = 'anonymous'
288288
if (cookie.has_key(self.cookie_name) and
289289
cookie[self.cookie_name].value != 'deleted'):

0 commit comments

Comments
 (0)