Mercurial > p > roundup > code
changeset 1781:c4968040459e maint-0.6
merge from HEAD
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 04 Sep 2003 23:09:48 +0000 |
| parents | ecfb6ccf20b0 |
| children | a1e38322bd19 |
| files | roundup/hyperdb.py roundup/instance.py templates/classic/detectors/nosyreaction.py templates/classic/detectors/statusauditor.py templates/classic/html/help_controls.js test/test_db.py |
| diffstat | 6 files changed, 66 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/hyperdb.py Sun Aug 31 04:31:03 2003 +0000 +++ b/roundup/hyperdb.py Thu Sep 04 23:09:48 2003 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: hyperdb.py,v 1.87 2003-03-17 22:03:03 kedder Exp $ +# $Id: hyperdb.py,v 1.87.2.1 2003-09-04 23:09:48 richard Exp $ """ Hyperdatabase implementation, especially field types. @@ -245,6 +245,8 @@ def getnode(self, classname, nodeid, db=None, cache=1): '''Get a node from the database. + + 'cache' exists for backwards compatibility, and is not used. ''' raise NotImplementedError @@ -365,10 +367,7 @@ IndexError is raised. 'propname' must be the name of a property of this class or a KeyError is raised. - 'cache' indicates whether the transaction cache should be queried - for the node. If the node has been modified and you need to - determine what its values prior to modification are, you need to - set cache=0. + 'cache' exists for backwards compatibility, and is not used. """ raise NotImplementedError @@ -378,12 +377,9 @@ 'nodeid' must be the id of an existing node of this class or an IndexError is raised. - 'cache' indicates whether the transaction cache should be queried - for the node. If the node has been modified and you need to - determine what its values prior to modification are, you need to - set cache=0. + 'cache' exists for backwards compatibility, and is not used. ''' - return Node(self, nodeid, cache=cache) + return Node(self, nodeid) def set(self, nodeid, **propvalues): """Modify a property on an existing node of this class. @@ -580,18 +576,17 @@ def __init__(self, cl, nodeid, cache=1): self.__dict__['cl'] = cl self.__dict__['nodeid'] = nodeid - self.__dict__['cache'] = cache def keys(self, protected=1): return self.cl.getprops(protected=protected).keys() def values(self, protected=1): l = [] for name in self.cl.getprops(protected=protected).keys(): - l.append(self.cl.get(self.nodeid, name, cache=self.cache)) + l.append(self.cl.get(self.nodeid, name)) return l def items(self, protected=1): l = [] for name in self.cl.getprops(protected=protected).keys(): - l.append((name, self.cl.get(self.nodeid, name, cache=self.cache))) + l.append((name, self.cl.get(self.nodeid, name))) return l def has_key(self, name): return self.cl.getprops().has_key(name) @@ -604,7 +599,7 @@ if self.__dict__.has_key(name): return self.__dict__[name] try: - return self.cl.get(self.nodeid, name, cache=self.cache) + return self.cl.get(self.nodeid, name) except KeyError, value: # we trap this but re-raise it as AttributeError - all other # exceptions should pass through untrapped @@ -612,7 +607,7 @@ # nope, no such attribute raise AttributeError, str(value) def __getitem__(self, name): - return self.cl.get(self.nodeid, name, cache=self.cache) + return self.cl.get(self.nodeid, name) def __setattr__(self, name, value): try: return self.cl.set(self.nodeid, **{name: value})
--- a/roundup/instance.py Sun Aug 31 04:31:03 2003 +0000 +++ b/roundup/instance.py Thu Sep 04 23:09:48 2003 +0000 @@ -15,21 +15,46 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: instance.py,v 1.9 2002-09-20 01:20:31 richard Exp $ +# $Id: instance.py,v 1.9.4.1 2003-09-04 23:09:48 richard Exp $ __doc__ = ''' Tracker handling (open tracker). -Currently this module provides one function: open. This function opens -a tracker. Note that trackers used to be called instances. +Backwards compatibility for the old-style "imported" trackers. ''' -import imp, os +import os + +class Vars: + ''' I'm just a container ''' + +class Tracker: + def __init__(self, tracker_home): + self.tracker_home = tracker_home + self.select_db = self._load_python('select_db.py') + self.config = self._load_config('config.py') + raise NotImplemented, 'this is *so* not finished' + self.init = XXX + self.Client = XXX + self.MailGW = XXX + + def open(self): + return self._load_config('schema.py').db + self._load_config('security.py', db=db) + + + def __load_python(self, file): + file = os.path.join(tracker_home, file) + vars = Vars() + execfile(file, vars.__dict__) + return vars + class TrackerError(Exception): pass -class Opener: + +class OldStyleTrackers: def __init__(self): self.number = 0 self.trackers = {} @@ -39,6 +64,7 @@ Raise ValueError if the tracker home doesn't exist. ''' + import imp # sanity check existence of tracker home if not os.path.exists(tracker_home): raise ValueError, 'no such directory: "%s"'%tracker_home @@ -67,11 +93,12 @@ return tracker -opener = Opener() -open = opener.open +OldStyleTrackers = OldStyleTrackers() +def open(tracker_home): + if os.path.exists(os.path.join(tracker_home, 'dbinit.py')): + # user should upgrade... + return OldStyleTrackers.open(tracker_home) -del Opener -del opener - + return Tracker(tracker_home) # vim: set filetype=python ts=4 sw=4 et si
--- a/templates/classic/detectors/nosyreaction.py Sun Aug 31 04:31:03 2003 +0000 +++ b/templates/classic/detectors/nosyreaction.py Thu Sep 04 23:09:48 2003 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: nosyreaction.py,v 1.1 2003-04-17 03:26:38 richard Exp $ +#$Id: nosyreaction.py,v 1.1.2.1 2003-09-04 23:09:48 richard Exp $ from roundup import roundupdb, hyperdb @@ -107,8 +107,8 @@ else: ok = ('yes',) # figure which of the messages now on the issue weren't - # there before - make sure we don't get a cached version! - oldmessages = cl.get(nodeid, 'messages', cache=0) + # there before + oldmessages = cl.get(nodeid, 'messages') messages = [] for msgid in newvalues['messages']: if msgid not in oldmessages:
--- a/templates/classic/detectors/statusauditor.py Sun Aug 31 04:31:03 2003 +0000 +++ b/templates/classic/detectors/statusauditor.py Thu Sep 04 23:09:48 2003 +0000 @@ -18,7 +18,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -#$Id: statusauditor.py,v 1.2 2003-06-25 09:49:34 neaj Exp $ +#$Id: statusauditor.py,v 1.2.2.1 2003-09-04 23:09:48 richard Exp $ def chatty(db, cl, nodeid, newvalues): ''' If the issue is currently 'unread', 'resolved' or 'done-cbb', then set @@ -27,7 +27,7 @@ # don't fire if there's no new message (ie. chat) if not newvalues.has_key('messages'): return - if newvalues['messages'] == cl.get(nodeid, 'messages', cache=0): + if newvalues['messages'] == cl.get(nodeid, 'messages'): return # get the chatting state ID
--- a/templates/classic/html/help_controls.js Sun Aug 31 04:31:03 2003 +0000 +++ b/templates/classic/html/help_controls.js Thu Sep 04 23:09:48 2003 +0000 @@ -53,6 +53,7 @@ function updateList() { // write back to opener window + if (document.frm_help.check==undefined) { return; } var list = new Array(); for (box=0; box < document.frm_help.check.length; box++) { if (document.frm_help.check[box].checked) { @@ -64,6 +65,7 @@ function updatePreview() { // add new checkbox selections to preview + if (document.frm_help.check==undefined) { return; } var list = new Array(); for (box=0; box < document.frm_help.check.length; box++) { if (document.frm_help.check[box].checked) { @@ -76,6 +78,7 @@ function clearList() { // uncheck all checkboxes + if (document.frm_help.check==undefined) { return; } for (box=0; box < document.frm_help.check.length; box++) { document.frm_help.check[box].checked = false; } @@ -83,6 +86,7 @@ function reviseList(vals) { // update the checkboxes based on the preview field + if (document.frm_help.check==undefined) { return; } var to_check; var list = vals.split(","); for (box=0; box < document.frm_help.check.length; box++) { @@ -100,6 +104,7 @@ function resetList() { // reset preview and check boxes to initial values + if (document.frm_help.check==undefined) { return; } var to_check; var list = original_field.split(','); writePreview(list);
--- a/test/test_db.py Sun Aug 31 04:31:03 2003 +0000 +++ b/test/test_db.py Thu Sep 04 23:09:48 2003 +0000 @@ -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.90 2003-08-12 02:22:22 richard Exp $ +# $Id: test_db.py,v 1.90.2.1 2003-09-04 23:09:48 richard Exp $ import unittest, os, shutil, time @@ -296,7 +296,14 @@ self.assertNotEqual(a, self.db.status.list()) # try to restore retired node self.db.status.restore('1') - self.assertEqual(a, self.db.status.list()) + + def testCacheCreateSet(self): + self.db.issue.create(title="spam", status='1') + a = self.db.issue.get('1', 'title') + self.assertEqual(a, 'spam') + self.db.issue.set('1', title='ham') + b = self.db.issue.get('1', 'title') + self.assertEqual(b, 'ham') def testSerialisation(self): nid = self.db.issue.create(title="spam", status='1',
