From c9a6e38350dadf4b07a6438ad3d6e85df95a3789 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 2 Dec 2001 05:06:16 +0000 Subject: [PATCH] . 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. . #487480 ] roundup-server . #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. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@443 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 5 + INSTALL.txt | 2 +- cgi-bin/roundup.cgi | 18 +++- roundup-admin | 42 ++++++++- roundup-mailgw | 9 +- roundup-server | 49 +++++----- roundup/backends/back_anydbm.py | 25 ++--- roundup/cgi_client.py | 136 ++++++++++++++------------- roundup/hyperdb.py | 20 ++-- roundup/mailgw.py | 14 ++- roundup/templates/classic/dbinit.py | 12 ++- roundup/templates/extended/dbinit.py | 12 ++- test/test_db.py | 10 +- 13 files changed, 217 insertions(+), 137 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 62bf811..bd0eb60 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,7 @@ Feature: the database when the commit() method is called. Only the anydbm backend is modified in this way - neither of the bsddb backends have been. + Fixed: . Lots of bugs, thanks Roché and others on the devel mailing list! . login_action and newuser_action return values were being ignored @@ -21,6 +22,10 @@ Fixed: gateway. . Fixed login/registration forwarding the user to the right page (or not, on a failure) + . We now use weakrefs in the Classes to keep the database reference, so + the close() method on the database is no longer needed. + . #487480 ] roundup-server + . #487476 ] INSTALL.txt 2001-11-23 - 0.3.0 diff --git a/INSTALL.txt b/INSTALL.txt index 7827dfe..272f94e 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -64,7 +64,7 @@ It may have the following variable declarations: MAIL_DOMAIN - The domain name used for email addresses Any further configuration should be possible by editing the instance home's -__init__.py directly. +instance_config.py directly. The email addresses used by the system by default are: diff --git a/cgi-bin/roundup.cgi b/cgi-bin/roundup.cgi index d327ee3..8434db1 100755 --- a/cgi-bin/roundup.cgi +++ b/cgi-bin/roundup.cgi @@ -16,13 +16,13 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundup.cgi,v 1.20 2001-11-26 22:55:56 richard Exp $ +# $Id: roundup.cgi,v 1.21 2001-12-02 05:06:16 richard Exp $ # python version check import sys -if int(sys.version[0]) < 2: +if not hasattr(sys, 'version_info') or sys.version_info[:2] < (2,1): print "Content-Type: text/plain\n" - print "Roundup requires Python 2.0 or newer." + print "Roundup requires Python 2.1 or newer." sys.exit(0) # @@ -200,6 +200,18 @@ LOG.close() # # $Log: not supported by cvs2svn $ +# Revision 1.20 2001/11/26 22:55:56 richard +# Feature: +# . Added INSTANCE_NAME to configuration - used in web and email to identify +# the instance. +# . Added EMAIL_SIGNATURE_POSITION to indicate where to place the roundup +# signature info in e-mails. +# . Some more flexibility in the mail gateway and more error handling. +# . Login now takes you to the page you back to the were denied access to. +# +# Fixed: +# . Lots of bugs, thanks Roché and others on the devel mailing list! +# # Revision 1.19 2001/11/22 00:25:10 richard # quick fix for file uploads on windows in roundup.cgi # diff --git a/roundup-admin b/roundup-admin index e5f48a6..948c566 100755 --- a/roundup-admin +++ b/roundup-admin @@ -16,11 +16,11 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundup-admin,v 1.49 2001-12-01 07:17:50 richard Exp $ +# $Id: roundup-admin,v 1.50 2001-12-02 05:06:16 richard Exp $ import sys -if int(sys.version[0]) < 2: - print 'Roundup requires python 2.0 or later.' +if not hasattr(sys, 'version_info') or sys.version_info[:2] < (2,1): + print 'Roundup requires python 2.1 or later.' sys.exit(1) import string, os, getpass, getopt, re, UserDict @@ -614,6 +614,32 @@ Command help: raise UsageError, 'no such %s node "%s"'%(classname, nodeid) return 0 + def do_commit(self, args): + '''Usage: commit + Commit all changes made to the database. + + The changes made during an interactive session are not + automatically written to the database - they must be committed + using this command. + + One-off commands on the command-line are automatically committed if + they are successful. + ''' + self.db.commit() + return 0 + + def do_rollback(self, args): + '''Usage: rollback + Undo all changes that are pending commit to the database. + + The changes made during an interactive session are not + automatically written to the database - they must be committed + manually. This command undoes all those changes, so a commit + immediately after would make no changes to the database. + ''' + self.db.commit() + return 0 + def do_retire(self, args): '''Usage: retire designator[,designator]* Retire the node specified by designator. @@ -883,7 +909,6 @@ Command help: else: ret = self.run_command(args) if self.db: self.db.commit() - if self.db: self.db.close() return ret @@ -893,6 +918,15 @@ if __name__ == '__main__': # # $Log: not supported by cvs2svn $ +# Revision 1.49 2001/12/01 07:17:50 richard +# . We now have basic transaction support! Information is only written to +# the database when the commit() method is called. Only the anydbm +# backend is modified in this way - neither of the bsddb backends have been. +# The mail, admin and cgi interfaces all use commit (except the admin tool +# doesn't have a commit command, so interactive users can't commit...) +# . Fixed login/registration forwarding the user to the right page (or not, +# on a failure) +# # Revision 1.48 2001/11/27 22:32:03 richard # typo # diff --git a/roundup-mailgw b/roundup-mailgw index 94623c5..9e3a006 100755 --- a/roundup-mailgw +++ b/roundup-mailgw @@ -16,11 +16,11 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundup-mailgw,v 1.16 2001-11-30 18:23:55 jhermann Exp $ +# $Id: roundup-mailgw,v 1.17 2001-12-02 05:06:16 richard Exp $ import sys, os, re, cStringIO -if int(sys.version[0]) < 2: - print "Roundup requires Python 2.0 or newer." +if not hasattr(sys, 'version_info') or sys.version_info[:2] < (2,1): + print "Roundup requires Python 2.1 or newer." sys.exit(1) from roundup.mailgw import Message @@ -168,6 +168,9 @@ if __name__ == '__main__': # # $Log: not supported by cvs2svn $ +# Revision 1.16 2001/11/30 18:23:55 jhermann +# Cleaned up strange import (less pollution, too) +# # Revision 1.15 2001/11/30 13:16:37 rochecompaan # Fixed bug. Mail gateway was not using the extended Message class # resulting in failed submissions when mails were processed from a Unix diff --git a/roundup-server b/roundup-server index 4ff953a..b56e644 100755 --- a/roundup-server +++ b/roundup-server @@ -20,13 +20,12 @@ Based on CGIHTTPServer in the Python library. -$Id: roundup-server,v 1.20 2001-11-26 22:55:56 richard Exp $ +$Id: roundup-server,v 1.21 2001-12-02 05:06:16 richard Exp $ """ import sys -if int(sys.version[0]) < 2: - print "Content-Type: text/plain\n" - print "Roundup requires Python 2.0 or newer." +if not hasattr(sys, 'version_info') or sys.version_info[:2] < (2,1): + print "Roundup requires Python 2.1 or newer." sys.exit(0) import os, urllib, StringIO, traceback, cgi, binascii, string, getopt, imp @@ -77,17 +76,18 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): except cgi_client.NotFound: self.send_error(404, self.path) except cgi_client.Unauthorised: - self.wfile.write('Content-Type: text/html\n') - self.wfile.write('Status: 403\n\n') - self.wfile.write('You are not authorised to access this URL.') + self.send_error(403, self.path) except: + # it'd be nice to be able to detect if these are going to have + # any effect... + self.send_response(400) + self.send_header('Content-Type', 'text/html') + self.end_headers() try: reload(cgitb) - self.wfile.write("Content-Type: text/html\n\n") self.wfile.write(cgitb.breaker()) self.wfile.write(cgitb.html()) except: - self.wfile.write("Content-Type: text/html\n\n") self.wfile.write("
")
                 s = StringIO.StringIO()
                 traceback.print_exc(None, s)
@@ -100,8 +100,10 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
     def index(self):
         ''' Print up an index of the available instances
         '''
+        self.send_response(200)
+        self.send_header('Content-Type', 'text/html')
+        self.end_headers()
         w = self.wfile.write
-        w("Content-Type: text/html\n\n")
         w('Roundup instances index\n')
         w('

Roundup instances index

    \n') for instance in self.ROUNDUP_INSTANCE_HOMES.keys(): @@ -161,21 +163,6 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): decoded_query = query.replace('+', ' ') - # reload all modules - # TODO check for file timestamp changes and dependencies - #reload(date) - #reload(hyperdb) - #reload(roundupdb) - #reload(htmltemplate) - #reload(cgi_client) - #sys.path.insert(0, module_path) - #try: - # reload(instance) - #finally: - # del sys.path[0] - - self.send_response(200, "Script output follows") - # do the roundup thang client = instance.Client(instance, self, env) client.main() @@ -262,6 +249,18 @@ if __name__ == '__main__': # # $Log: not supported by cvs2svn $ +# Revision 1.20 2001/11/26 22:55:56 richard +# Feature: +# . Added INSTANCE_NAME to configuration - used in web and email to identify +# the instance. +# . Added EMAIL_SIGNATURE_POSITION to indicate where to place the roundup +# signature info in e-mails. +# . Some more flexibility in the mail gateway and more error handling. +# . Login now takes you to the page you back to the were denied access to. +# +# Fixed: +# . Lots of bugs, thanks Roché and others on the devel mailing list! +# # Revision 1.19 2001/11/12 22:51:04 jhermann # Fixed option & associated error handling # diff --git a/roundup/backends/back_anydbm.py b/roundup/backends/back_anydbm.py index 38305b5..156857e 100644 --- a/roundup/backends/back_anydbm.py +++ b/roundup/backends/back_anydbm.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_anydbm.py,v 1.12 2001-12-01 07:17:50 richard Exp $ +#$Id: back_anydbm.py,v 1.13 2001-12-02 05:06:16 richard Exp $ import anydbm, os, marshal from roundup import hyperdb, date, password @@ -134,7 +134,6 @@ class Database(hyperdb.Database): if not db.has_key(nodeid): raise IndexError, nodeid res = marshal.loads(db[nodeid]) - if not cldb: db.close() cache[nodeid] = res return res @@ -149,7 +148,6 @@ class Database(hyperdb.Database): # not in the cache - check the database db = cldb or self.getclassdb(classname) res = db.has_key(nodeid) - if not cldb: db.close() return res def countnodes(self, classname, cldb=None): @@ -159,7 +157,6 @@ class Database(hyperdb.Database): # and count those in the DB db = cldb or self.getclassdb(classname) count = count + len(db.keys()) - if not cldb: db.close() return count def getnodeids(self, classname, cldb=None): @@ -168,7 +165,6 @@ class Database(hyperdb.Database): db = cldb or self.getclassdb(classname) res = res + db.keys() - if not cldb: db.close() return res # @@ -202,17 +198,8 @@ class Database(hyperdb.Database): (nodeid, date_stamp, self.journaltag, action, params) = entry date_obj = date.Date(date_stamp) res.append((nodeid, date_obj, self.journaltag, action, params)) - db.close() return res - def close(self): - ''' Close the Database. - - Commit all data to the database and release circular refs so - the database is closed cleanly. - ''' - self.classes = {} - # # Basic transaction support @@ -222,7 +209,6 @@ class Database(hyperdb.Database): ''' # lock the DB for method, args in self.transactions: - print method.__name__, args # TODO: optimise this, duh! method(*args) # unlock the DB @@ -262,6 +248,15 @@ class Database(hyperdb.Database): # #$Log: not supported by cvs2svn $ +#Revision 1.12 2001/12/01 07:17:50 richard +#. We now have basic transaction support! Information is only written to +# the database when the commit() method is called. Only the anydbm +# backend is modified in this way - neither of the bsddb backends have been. +# The mail, admin and cgi interfaces all use commit (except the admin tool +# doesn't have a commit command, so interactive users can't commit...) +#. Fixed login/registration forwarding the user to the right page (or not, +# on a failure) +# #Revision 1.11 2001/11/21 02:34:18 richard #Added a target version field to the extended issue schema # diff --git a/roundup/cgi_client.py b/roundup/cgi_client.py index 451ae5b..f7075ea 100644 --- a/roundup/cgi_client.py +++ b/roundup/cgi_client.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: cgi_client.py,v 1.73 2001-12-01 07:17:50 richard Exp $ +# $Id: cgi_client.py,v 1.74 2001-12-02 05:06:16 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -327,16 +327,15 @@ class Client: props['status'] == resolved_id): props['status'] = chatting_id changed.append('status') - note = None - if self.form.has_key('__note'): - note = self.form['__note'] - note = note.value - if changed or note: - p = self._post_editnode(self.nodeid, changed) - props['messages'] = p['messages'] - props['files'] = p['files'] - cl.set(self.nodeid, **props) - # and some nice feedback for the user + + # make the changes + cl.set(self.nodeid, **props) + + # handle linked nodes and change message generation + self._post_editnode(self.nodeid, changed) + + # and some nice feedback for the user + if changed: message = _('%(changes)s edited ok')%{'changes': ', '.join(changed)} else: @@ -476,40 +475,54 @@ class Client: # create the new file entry files.append(self.db.file.create(type=mime_type, name=file.filename, content=file.file.read())) + # and save the reference + cl.set(nid, files=files) + if changes is not None and 'file' not in changes: + changes.append('file') + # # generate an edit message - # don't bother if there's no messages or nosy list + # + + # we don't want to do a message if none of the following is true... props = cl.getprops() note = None if self.form.has_key('__note'): note = self.form['__note'] note = note.value - send = len(cl.get(nid, 'nosy', [])) or note - if (send and props.has_key('messages') and - isinstance(props['messages'], hyperdb.Multilink) and - props['messages'].classname == 'msg'): - - # handle the note - if note: - if '\n' in note: - summary = re.split(r'\n\r?', note)[0] - else: - summary = note - m = ['%s\n'%note] + if not props.has_key('messages'): + return + if not isinstance(props['messages'], hyperdb.Multilink): + return + if not props['messages'].classname == 'msg': + return + if not (len(cl.get(nid, 'nosy', [])) or note): + return + + # handle the note + if note: + if '\n' in note: + summary = re.split(r'\n\r?', note)[0] else: - summary = _('This %(classname)s has been edited through' - ' the web.\n')%{'classname': cn} - m = [summary] - - # now create the message - content = '\n'.join(m) - message_id = self.db.msg.create(author=self.getuid(), - recipients=[], date=date.Date('.'), summary=summary, - content=content, files=files) - messages = cl.get(nid, 'messages') - messages.append(message_id) - props = {'messages': messages, 'files': files} - return props + summary = note + m = ['%s\n'%note] + else: + summary = _('This %(classname)s has been edited through' + ' the web.\n')%{'classname': cn} + m = [summary] + + # TODO: append the change note! + + # now create the message + content = '\n'.join(m) + message_id = self.db.msg.create(author=self.getuid(), + recipients=[], date=date.Date('.'), summary=summary, + content=content, files=files) + + # update the messages property + messages = cl.get(nid, 'messages') + messages.append(message_id) + cl.set(nid, messages=messages, files=files) def newnode(self, message=None): ''' Add a new node to the database. @@ -542,8 +555,8 @@ class Client: props = {} try: nid = self._createnode() - props = self._post_editnode(nid) - cl.set(nid, **props) + # handle linked nodes and change message generation + self._post_editnode(nid) # and some nice feedback for the user message = _('%(classname)s created ok')%{'classname': cn} except: @@ -579,8 +592,11 @@ class Client: mime_type = mimetypes.guess_type(file.filename)[0] if not mime_type: mime_type = "application/octet-stream" - self._post_editnode(cl.create(content=file.file.read(), - type=mime_type, name=file.filename)) + # save the file + nid = cl.create(content=file.file.read(), type=mime_type, + name=file.filename) + # handle linked nodes + self._post_editnode(nid) # and some nice feedback for the user message = _('%(classname)s created ok')%{'classname': cn} except: @@ -713,7 +729,6 @@ class Client: return 1 on successful login ''' # re-open the database as "admin" - self.db.close() self.db = self.instance.open('admin') # TODO: pre-check the required fields and username key property @@ -767,25 +782,6 @@ class Client: ''' # determine the uid to use self.db = self.instance.open('admin') - try: - self.main_user() - finally: - self.db.close() - - # re-open the database for real, using the user - self.db = self.instance.open(self.user) - try: - self.main_action() - except: - self.db.close() - raise - self.db.commit() - self.db.close() - - - def main_user(self): - '''Figure out who the user is - ''' cookie = Cookie.Cookie(self.env.get('HTTP_COOKIE', '')) user = 'anonymous' if (cookie.has_key('roundup_user') and @@ -814,11 +810,9 @@ class Client: else: self.user = user + # re-open the database for real, using the user + self.db = self.instance.open(self.user) - def main_action(self): - '''Check for appropriate access permission, and then perform the - action the users specifies - ''' # now figure which function to call path = self.split_path @@ -874,6 +868,9 @@ class Client: # just a regular action self.do_action(action) + # commit all changes to the database + self.db.commit() + def do_action(self, action, dre=re.compile(r'([^\d]+)(\d+)'), nre=re.compile(r'new(\w+)')): '''Figure the user's action and do it. @@ -1071,6 +1068,15 @@ def parsePropsFromForm(db, cl, form, nodeid=0): # # $Log: not supported by cvs2svn $ +# Revision 1.73 2001/12/01 07:17:50 richard +# . We now have basic transaction support! Information is only written to +# the database when the commit() method is called. Only the anydbm +# backend is modified in this way - neither of the bsddb backends have been. +# The mail, admin and cgi interfaces all use commit (except the admin tool +# doesn't have a commit command, so interactive users can't commit...) +# . Fixed login/registration forwarding the user to the right page (or not, +# on a failure) +# # Revision 1.72 2001/11/30 20:47:58 rochecompaan # Links in page header are now consistent with default sort order. # diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py index 779db22..bfcd921 100644 --- a/roundup/hyperdb.py +++ b/roundup/hyperdb.py @@ -15,14 +15,14 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: hyperdb.py,v 1.38 2001-12-01 07:17:50 richard Exp $ +# $Id: hyperdb.py,v 1.39 2001-12-02 05:06:16 richard Exp $ __doc__ = """ Hyperdatabase implementation, especially field types. """ # standard python modules -import cPickle, re, string +import cPickle, re, string, weakref # roundup modules import date, password @@ -96,7 +96,7 @@ class Class: """ self.classname = classname self.properties = properties - self.db = db + self.db = weakref.proxy(db) # use a weak ref to avoid circularity self.key = '' # do the db-related init stuff @@ -495,7 +495,6 @@ class Class: continue if node[self.key] == keyvalue: return nodeid - cldb.close() raise KeyError, keyvalue # XXX: change from spec - allows multiple props to match @@ -532,7 +531,6 @@ class Class: l.append(id) elif isinstance(prop, Multilink) and nodeid in property: l.append(id) - cldb.close() return l def stringFind(self, **requirements): @@ -559,7 +557,6 @@ class Class: break else: l.append(nodeid) - cldb.close() return l def list(self): @@ -573,7 +570,6 @@ class Class: continue l.append(nodeid) l.sort() - cldb.close() return l # XXX not in spec @@ -666,7 +662,6 @@ class Class: else: l.append((nodeid, node)) l.sort() - cldb.close() # optimise sort m = [] @@ -873,6 +868,15 @@ def Choice(name, *options): # # $Log: not supported by cvs2svn $ +# Revision 1.38 2001/12/01 07:17:50 richard +# . We now have basic transaction support! Information is only written to +# the database when the commit() method is called. Only the anydbm +# backend is modified in this way - neither of the bsddb backends have been. +# The mail, admin and cgi interfaces all use commit (except the admin tool +# doesn't have a commit command, so interactive users can't commit...) +# . Fixed login/registration forwarding the user to the right page (or not, +# on a failure) +# # Revision 1.37 2001/11/28 21:55:35 richard # . login_action and newuser_action return values were being ignored # . Woohoo! Found that bloody re-login bug that was killing the mail diff --git a/roundup/mailgw.py b/roundup/mailgw.py index fb4c84b..f3c1f4c 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -73,7 +73,7 @@ are calling the create() method to create a new node). If an auditor raises an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.38 2001-12-01 07:17:50 richard Exp $ +$Id: mailgw.py,v 1.39 2001-12-02 05:06:16 richard Exp $ ''' @@ -352,11 +352,8 @@ Subject was: "%s" author = self.db.uidFromAddress(message.getaddrlist('from')[0]) # reopen the database as the author username = self.db.user.get(author, 'username') - self.db.close() self.db = self.instance.open(username) - self.handle_message(author, username, - # re-get the class with the new database connection cl = self.db.getclass(classname) @@ -601,6 +598,15 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'), # # $Log: not supported by cvs2svn $ +# Revision 1.38 2001/12/01 07:17:50 richard +# . We now have basic transaction support! Information is only written to +# the database when the commit() method is called. Only the anydbm +# backend is modified in this way - neither of the bsddb backends have been. +# The mail, admin and cgi interfaces all use commit (except the admin tool +# doesn't have a commit command, so interactive users can't commit...) +# . Fixed login/registration forwarding the user to the right page (or not, +# on a failure) +# # Revision 1.37 2001/11/28 21:55:35 richard # . login_action and newuser_action return values were being ignored # . Woohoo! Found that bloody re-login bug that was killing the mail diff --git a/roundup/templates/classic/dbinit.py b/roundup/templates/classic/dbinit.py index 4a9e2b0..865ee75 100644 --- a/roundup/templates/classic/dbinit.py +++ b/roundup/templates/classic/dbinit.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: dbinit.py,v 1.11 2001-12-01 07:17:50 richard Exp $ +# $Id: dbinit.py,v 1.12 2001-12-02 05:06:16 richard Exp $ import os @@ -124,10 +124,18 @@ def init(adminpw): user.create(username="admin", password=adminpw, address=instance_config.ADMIN_EMAIL) db.commit() - db.close() # # $Log: not supported by cvs2svn $ +# Revision 1.11 2001/12/01 07:17:50 richard +# . We now have basic transaction support! Information is only written to +# the database when the commit() method is called. Only the anydbm +# backend is modified in this way - neither of the bsddb backends have been. +# The mail, admin and cgi interfaces all use commit (except the admin tool +# doesn't have a commit command, so interactive users can't commit...) +# . Fixed login/registration forwarding the user to the right page (or not, +# on a failure) +# # Revision 1.10 2001/11/26 22:55:56 richard # Feature: # . Added INSTANCE_NAME to configuration - used in web and email to identify diff --git a/roundup/templates/extended/dbinit.py b/roundup/templates/extended/dbinit.py index e97c284..57cb45c 100644 --- a/roundup/templates/extended/dbinit.py +++ b/roundup/templates/extended/dbinit.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: dbinit.py,v 1.16 2001-12-01 07:17:50 richard Exp $ +# $Id: dbinit.py,v 1.17 2001-12-02 05:06:16 richard Exp $ import os @@ -175,10 +175,18 @@ def init(adminpw): address=instance_config.ADMIN_EMAIL) db.commit() - db.close() # # $Log: not supported by cvs2svn $ +# Revision 1.16 2001/12/01 07:17:50 richard +# . We now have basic transaction support! Information is only written to +# the database when the commit() method is called. Only the anydbm +# backend is modified in this way - neither of the bsddb backends have been. +# The mail, admin and cgi interfaces all use commit (except the admin tool +# doesn't have a commit command, so interactive users can't commit...) +# . Fixed login/registration forwarding the user to the right page (or not, +# on a failure) +# # Revision 1.15 2001/11/26 22:55:56 richard # Feature: # . Added INSTANCE_NAME to configuration - used in web and email to identify diff --git a/test/test_db.py b/test/test_db.py index 83da8f1..61c08a6 100644 --- a/test/test_db.py +++ b/test/test_db.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: test_db.py,v 1.8 2001-10-09 07:25:59 richard Exp $ +# $Id: test_db.py,v 1.9 2001-12-02 05:06:16 richard Exp $ import unittest, os, shutil @@ -50,7 +50,6 @@ class MyTestCase(unittest.TestCase): # return MyTestResult() def tearDown(self): if self.db is not None: - self.db.close() shutil.rmtree('_test_dir') class DBTestCase(MyTestCase): @@ -158,7 +157,6 @@ class ReadOnlyDBTestCase(MyTestCase): os.mkdir('_test_dir') db = anydbm.Database('_test_dir', 'test') setupSchema(db, 1) - db.close() self.db = anydbm.Database('_test_dir') setupSchema(self.db, 0) @@ -191,7 +189,6 @@ class bsddbReadOnlyDBTestCase(ReadOnlyDBTestCase): os.mkdir('_test_dir') db = bsddb.Database('_test_dir', 'test') setupSchema(db, 1) - db.close() self.db = bsddb.Database('_test_dir') setupSchema(self.db, 0) @@ -215,7 +212,6 @@ class bsddb3ReadOnlyDBTestCase(ReadOnlyDBTestCase): os.mkdir('_test_dir') db = bsddb3.Database('_test_dir', 'test') setupSchema(db, 1) - db.close() self.db = bsddb3.Database('_test_dir') setupSchema(self.db, 0) @@ -242,6 +238,10 @@ def suite(): # # $Log: not supported by cvs2svn $ +# Revision 1.8 2001/10/09 07:25:59 richard +# Added the Password property type. See "pydoc roundup.password" for +# implementation details. Have updated some of the documentation too. +# # Revision 1.7 2001/08/29 06:23:59 richard # Disabled the bsddb3 module entirely in the unit testing. See CHANGES for # details. -- 2.30.2