Skip to content

Commit a4accff

Browse files
author
Richard Jones
committed
Eliminate database close method by using weakrefs.
. We now use weakrefs in the Classes to keep the database reference, so the close() method on the database is no longer needed. I bumped the minimum python requirement up to 2.1 accordingly. . [SF#487480] roundup-server . [SF#487476] INSTALL.txt I also cleaned up the change message / post-edit stuff in the cgi client. There's now a clearly marked "TODO: append the change note" where I believe the change note should be added there. The "changes" list will obviously have to be modified to be a dict of the changes, or somesuch. More testing needed.
1 parent 60f2ef2 commit a4accff

File tree

13 files changed

+217
-137
lines changed

13 files changed

+217
-137
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@ Feature:
1414
the database when the commit() method is called. Only the anydbm backend
1515
is modified in this way - neither of the bsddb backends have been.
1616

17+
1718
Fixed:
1819
. Lots of bugs, thanks Roch� and others on the devel mailing list!
1920
. login_action and newuser_action return values were being ignored
2021
. Woohoo! Found that bloody re-login bug that was killing the mail
2122
gateway.
2223
. Fixed login/registration forwarding the user to the right page (or not,
2324
on a failure)
25+
. We now use weakrefs in the Classes to keep the database reference, so
26+
the close() method on the database is no longer needed.
27+
. #487480 ] roundup-server
28+
. #487476 ] INSTALL.txt
2429

2530

2631
2001-11-23 - 0.3.0

INSTALL.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ It may have the following variable declarations:
6464
MAIL_DOMAIN - The domain name used for email addresses
6565

6666
Any further configuration should be possible by editing the instance home's
67-
__init__.py directly.
67+
instance_config.py directly.
6868

6969
The email addresses used by the system by default are:
7070

cgi-bin/roundup.cgi

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: roundup.cgi,v 1.20 2001-11-26 22:55:56 richard Exp $
19+
# $Id: roundup.cgi,v 1.21 2001-12-02 05:06:16 richard Exp $
2020

2121
# python version check
2222
import sys
23-
if int(sys.version[0]) < 2:
23+
if not hasattr(sys, 'version_info') or sys.version_info[:2] < (2,1):
2424
print "Content-Type: text/plain\n"
25-
print "Roundup requires Python 2.0 or newer."
25+
print "Roundup requires Python 2.1 or newer."
2626
sys.exit(0)
2727

2828
#
@@ -200,6 +200,18 @@ LOG.close()
200200

201201
#
202202
# $Log: not supported by cvs2svn $
203+
# Revision 1.20 2001/11/26 22:55:56 richard
204+
# Feature:
205+
# . Added INSTANCE_NAME to configuration - used in web and email to identify
206+
# the instance.
207+
# . Added EMAIL_SIGNATURE_POSITION to indicate where to place the roundup
208+
# signature info in e-mails.
209+
# . Some more flexibility in the mail gateway and more error handling.
210+
# . Login now takes you to the page you back to the were denied access to.
211+
#
212+
# Fixed:
213+
# . Lots of bugs, thanks Roché and others on the devel mailing list!
214+
#
203215
# Revision 1.19 2001/11/22 00:25:10 richard
204216
# quick fix for file uploads on windows in roundup.cgi
205217
#

roundup-admin

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: roundup-admin,v 1.49 2001-12-01 07:17:50 richard Exp $
19+
# $Id: roundup-admin,v 1.50 2001-12-02 05:06:16 richard Exp $
2020

2121
import sys
22-
if int(sys.version[0]) < 2:
23-
print 'Roundup requires python 2.0 or later.'
22+
if not hasattr(sys, 'version_info') or sys.version_info[:2] < (2,1):
23+
print 'Roundup requires python 2.1 or later.'
2424
sys.exit(1)
2525

2626
import string, os, getpass, getopt, re, UserDict
@@ -614,6 +614,32 @@ Command help:
614614
raise UsageError, 'no such %s node "%s"'%(classname, nodeid)
615615
return 0
616616

617+
def do_commit(self, args):
618+
'''Usage: commit
619+
Commit all changes made to the database.
620+
621+
The changes made during an interactive session are not
622+
automatically written to the database - they must be committed
623+
using this command.
624+
625+
One-off commands on the command-line are automatically committed if
626+
they are successful.
627+
'''
628+
self.db.commit()
629+
return 0
630+
631+
def do_rollback(self, args):
632+
'''Usage: rollback
633+
Undo all changes that are pending commit to the database.
634+
635+
The changes made during an interactive session are not
636+
automatically written to the database - they must be committed
637+
manually. This command undoes all those changes, so a commit
638+
immediately after would make no changes to the database.
639+
'''
640+
self.db.commit()
641+
return 0
642+
617643
def do_retire(self, args):
618644
'''Usage: retire designator[,designator]*
619645
Retire the node specified by designator.
@@ -883,7 +909,6 @@ Command help:
883909
else:
884910
ret = self.run_command(args)
885911
if self.db: self.db.commit()
886-
if self.db: self.db.close()
887912
return ret
888913

889914

@@ -893,6 +918,15 @@ if __name__ == '__main__':
893918

894919
#
895920
# $Log: not supported by cvs2svn $
921+
# Revision 1.49 2001/12/01 07:17:50 richard
922+
# . We now have basic transaction support! Information is only written to
923+
# the database when the commit() method is called. Only the anydbm
924+
# backend is modified in this way - neither of the bsddb backends have been.
925+
# The mail, admin and cgi interfaces all use commit (except the admin tool
926+
# doesn't have a commit command, so interactive users can't commit...)
927+
# . Fixed login/registration forwarding the user to the right page (or not,
928+
# on a failure)
929+
#
896930
# Revision 1.48 2001/11/27 22:32:03 richard
897931
# typo
898932
#

roundup-mailgw

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: roundup-mailgw,v 1.16 2001-11-30 18:23:55 jhermann Exp $
19+
# $Id: roundup-mailgw,v 1.17 2001-12-02 05:06:16 richard Exp $
2020

2121
import sys, os, re, cStringIO
22-
if int(sys.version[0]) < 2:
23-
print "Roundup requires Python 2.0 or newer."
22+
if not hasattr(sys, 'version_info') or sys.version_info[:2] < (2,1):
23+
print "Roundup requires Python 2.1 or newer."
2424
sys.exit(1)
2525

2626
from roundup.mailgw import Message
@@ -168,6 +168,9 @@ if __name__ == '__main__':
168168

169169
#
170170
# $Log: not supported by cvs2svn $
171+
# Revision 1.16 2001/11/30 18:23:55 jhermann
172+
# Cleaned up strange import (less pollution, too)
173+
#
171174
# Revision 1.15 2001/11/30 13:16:37 rochecompaan
172175
# Fixed bug. Mail gateway was not using the extended Message class
173176
# resulting in failed submissions when mails were processed from a Unix

roundup-server

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@
2020
2121
Based on CGIHTTPServer in the Python library.
2222
23-
$Id: roundup-server,v 1.20 2001-11-26 22:55:56 richard Exp $
23+
$Id: roundup-server,v 1.21 2001-12-02 05:06:16 richard Exp $
2424
2525
"""
2626
import sys
27-
if int(sys.version[0]) < 2:
28-
print "Content-Type: text/plain\n"
29-
print "Roundup requires Python 2.0 or newer."
27+
if not hasattr(sys, 'version_info') or sys.version_info[:2] < (2,1):
28+
print "Roundup requires Python 2.1 or newer."
3029
sys.exit(0)
3130

3231
import os, urllib, StringIO, traceback, cgi, binascii, string, getopt, imp
@@ -77,17 +76,18 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
7776
except cgi_client.NotFound:
7877
self.send_error(404, self.path)
7978
except cgi_client.Unauthorised:
80-
self.wfile.write('Content-Type: text/html\n')
81-
self.wfile.write('Status: 403\n\n')
82-
self.wfile.write('You are not authorised to access this URL.')
79+
self.send_error(403, self.path)
8380
except:
81+
# it'd be nice to be able to detect if these are going to have
82+
# any effect...
83+
self.send_response(400)
84+
self.send_header('Content-Type', 'text/html')
85+
self.end_headers()
8486
try:
8587
reload(cgitb)
86-
self.wfile.write("Content-Type: text/html\n\n")
8788
self.wfile.write(cgitb.breaker())
8889
self.wfile.write(cgitb.html())
8990
except:
90-
self.wfile.write("Content-Type: text/html\n\n")
9191
self.wfile.write("<pre>")
9292
s = StringIO.StringIO()
9393
traceback.print_exc(None, s)
@@ -100,8 +100,10 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
100100
def index(self):
101101
''' Print up an index of the available instances
102102
'''
103+
self.send_response(200)
104+
self.send_header('Content-Type', 'text/html')
105+
self.end_headers()
103106
w = self.wfile.write
104-
w("Content-Type: text/html\n\n")
105107
w('<html><head><title>Roundup instances index</title></head>\n')
106108
w('<body><h1>Roundup instances index</h1><ol>\n')
107109
for instance in self.ROUNDUP_INSTANCE_HOMES.keys():
@@ -161,21 +163,6 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
161163

162164
decoded_query = query.replace('+', ' ')
163165

164-
# reload all modules
165-
# TODO check for file timestamp changes and dependencies
166-
#reload(date)
167-
#reload(hyperdb)
168-
#reload(roundupdb)
169-
#reload(htmltemplate)
170-
#reload(cgi_client)
171-
#sys.path.insert(0, module_path)
172-
#try:
173-
# reload(instance)
174-
#finally:
175-
# del sys.path[0]
176-
177-
self.send_response(200, "Script output follows")
178-
179166
# do the roundup thang
180167
client = instance.Client(instance, self, env)
181168
client.main()
@@ -262,6 +249,18 @@ if __name__ == '__main__':
262249

263250
#
264251
# $Log: not supported by cvs2svn $
252+
# Revision 1.20 2001/11/26 22:55:56 richard
253+
# Feature:
254+
# . Added INSTANCE_NAME to configuration - used in web and email to identify
255+
# the instance.
256+
# . Added EMAIL_SIGNATURE_POSITION to indicate where to place the roundup
257+
# signature info in e-mails.
258+
# . Some more flexibility in the mail gateway and more error handling.
259+
# . Login now takes you to the page you back to the were denied access to.
260+
#
261+
# Fixed:
262+
# . Lots of bugs, thanks Roché and others on the devel mailing list!
263+
#
265264
# Revision 1.19 2001/11/12 22:51:04 jhermann
266265
# Fixed option & associated error handling
267266
#

roundup/backends/back_anydbm.py

Lines changed: 10 additions & 15 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: back_anydbm.py,v 1.12 2001-12-01 07:17:50 richard Exp $
18+
#$Id: back_anydbm.py,v 1.13 2001-12-02 05:06:16 richard Exp $
1919

2020
import anydbm, os, marshal
2121
from roundup import hyperdb, date, password
@@ -134,7 +134,6 @@ def getnode(self, classname, nodeid, cldb=None):
134134
if not db.has_key(nodeid):
135135
raise IndexError, nodeid
136136
res = marshal.loads(db[nodeid])
137-
if not cldb: db.close()
138137
cache[nodeid] = res
139138
return res
140139

@@ -149,7 +148,6 @@ def hasnode(self, classname, nodeid, cldb=None):
149148
# not in the cache - check the database
150149
db = cldb or self.getclassdb(classname)
151150
res = db.has_key(nodeid)
152-
if not cldb: db.close()
153151
return res
154152

155153
def countnodes(self, classname, cldb=None):
@@ -159,7 +157,6 @@ def countnodes(self, classname, cldb=None):
159157
# and count those in the DB
160158
db = cldb or self.getclassdb(classname)
161159
count = count + len(db.keys())
162-
if not cldb: db.close()
163160
return count
164161

165162
def getnodeids(self, classname, cldb=None):
@@ -168,7 +165,6 @@ def getnodeids(self, classname, cldb=None):
168165

169166
db = cldb or self.getclassdb(classname)
170167
res = res + db.keys()
171-
if not cldb: db.close()
172168
return res
173169

174170
#
@@ -202,17 +198,8 @@ def getjournal(self, classname, nodeid):
202198
(nodeid, date_stamp, self.journaltag, action, params) = entry
203199
date_obj = date.Date(date_stamp)
204200
res.append((nodeid, date_obj, self.journaltag, action, params))
205-
db.close()
206201
return res
207202

208-
def close(self):
209-
''' Close the Database.
210-
211-
Commit all data to the database and release circular refs so
212-
the database is closed cleanly.
213-
'''
214-
self.classes = {}
215-
216203

217204
#
218205
# Basic transaction support
@@ -222,7 +209,6 @@ def commit(self):
222209
'''
223210
# lock the DB
224211
for method, args in self.transactions:
225-
print method.__name__, args
226212
# TODO: optimise this, duh!
227213
method(*args)
228214
# unlock the DB
@@ -262,6 +248,15 @@ def rollback(self):
262248

263249
#
264250
#$Log: not supported by cvs2svn $
251+
#Revision 1.12 2001/12/01 07:17:50 richard
252+
#. We now have basic transaction support! Information is only written to
253+
# the database when the commit() method is called. Only the anydbm
254+
# backend is modified in this way - neither of the bsddb backends have been.
255+
# The mail, admin and cgi interfaces all use commit (except the admin tool
256+
# doesn't have a commit command, so interactive users can't commit...)
257+
#. Fixed login/registration forwarding the user to the right page (or not,
258+
# on a failure)
259+
#
265260
#Revision 1.11 2001/11/21 02:34:18 richard
266261
#Added a target version field to the extended issue schema
267262
#

0 commit comments

Comments
 (0)