Skip to content

Commit ef1e71d

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent 32ef7b3 commit ef1e71d

File tree

6 files changed

+66
-32
lines changed

6 files changed

+66
-32
lines changed

roundup/hyperdb.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: hyperdb.py,v 1.87 2003-03-17 22:03:03 kedder Exp $
18+
# $Id: hyperdb.py,v 1.87.2.1 2003-09-04 23:09:48 richard Exp $
1919

2020
"""
2121
Hyperdatabase implementation, especially field types.
@@ -245,6 +245,8 @@ def unserialise(self, classname, node):
245245

246246
def getnode(self, classname, nodeid, db=None, cache=1):
247247
'''Get a node from the database.
248+
249+
'cache' exists for backwards compatibility, and is not used.
248250
'''
249251
raise NotImplementedError
250252

@@ -365,10 +367,7 @@ def get(self, nodeid, propname, default=_marker, cache=1):
365367
IndexError is raised. 'propname' must be the name of a property
366368
of this class or a KeyError is raised.
367369
368-
'cache' indicates whether the transaction cache should be queried
369-
for the node. If the node has been modified and you need to
370-
determine what its values prior to modification are, you need to
371-
set cache=0.
370+
'cache' exists for backwards compatibility, and is not used.
372371
"""
373372
raise NotImplementedError
374373

@@ -378,12 +377,9 @@ def getnode(self, nodeid, cache=1):
378377
'nodeid' must be the id of an existing node of this class or an
379378
IndexError is raised.
380379
381-
'cache' indicates whether the transaction cache should be queried
382-
for the node. If the node has been modified and you need to
383-
determine what its values prior to modification are, you need to
384-
set cache=0.
380+
'cache' exists for backwards compatibility, and is not used.
385381
'''
386-
return Node(self, nodeid, cache=cache)
382+
return Node(self, nodeid)
387383

388384
def set(self, nodeid, **propvalues):
389385
"""Modify a property on an existing node of this class.
@@ -580,18 +576,17 @@ class Node:
580576
def __init__(self, cl, nodeid, cache=1):
581577
self.__dict__['cl'] = cl
582578
self.__dict__['nodeid'] = nodeid
583-
self.__dict__['cache'] = cache
584579
def keys(self, protected=1):
585580
return self.cl.getprops(protected=protected).keys()
586581
def values(self, protected=1):
587582
l = []
588583
for name in self.cl.getprops(protected=protected).keys():
589-
l.append(self.cl.get(self.nodeid, name, cache=self.cache))
584+
l.append(self.cl.get(self.nodeid, name))
590585
return l
591586
def items(self, protected=1):
592587
l = []
593588
for name in self.cl.getprops(protected=protected).keys():
594-
l.append((name, self.cl.get(self.nodeid, name, cache=self.cache)))
589+
l.append((name, self.cl.get(self.nodeid, name)))
595590
return l
596591
def has_key(self, name):
597592
return self.cl.getprops().has_key(name)
@@ -604,15 +599,15 @@ def __getattr__(self, name):
604599
if self.__dict__.has_key(name):
605600
return self.__dict__[name]
606601
try:
607-
return self.cl.get(self.nodeid, name, cache=self.cache)
602+
return self.cl.get(self.nodeid, name)
608603
except KeyError, value:
609604
# we trap this but re-raise it as AttributeError - all other
610605
# exceptions should pass through untrapped
611606
pass
612607
# nope, no such attribute
613608
raise AttributeError, str(value)
614609
def __getitem__(self, name):
615-
return self.cl.get(self.nodeid, name, cache=self.cache)
610+
return self.cl.get(self.nodeid, name)
616611
def __setattr__(self, name, value):
617612
try:
618613
return self.cl.set(self.nodeid, **{name: value})

roundup/instance.py

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,46 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: instance.py,v 1.9 2002-09-20 01:20:31 richard Exp $
18+
# $Id: instance.py,v 1.9.4.1 2003-09-04 23:09:48 richard Exp $
1919

2020
__doc__ = '''
2121
Tracker handling (open tracker).
2222
23-
Currently this module provides one function: open. This function opens
24-
a tracker. Note that trackers used to be called instances.
23+
Backwards compatibility for the old-style "imported" trackers.
2524
'''
2625

27-
import imp, os
26+
import os
27+
28+
class Vars:
29+
''' I'm just a container '''
30+
31+
class Tracker:
32+
def __init__(self, tracker_home):
33+
self.tracker_home = tracker_home
34+
self.select_db = self._load_python('select_db.py')
35+
self.config = self._load_config('config.py')
36+
raise NotImplemented, 'this is *so* not finished'
37+
self.init = XXX
38+
self.Client = XXX
39+
self.MailGW = XXX
40+
41+
def open(self):
42+
return self._load_config('schema.py').db
43+
self._load_config('security.py', db=db)
44+
45+
46+
def __load_python(self, file):
47+
file = os.path.join(tracker_home, file)
48+
vars = Vars()
49+
execfile(file, vars.__dict__)
50+
return vars
51+
2852

2953
class TrackerError(Exception):
3054
pass
3155

32-
class Opener:
56+
57+
class OldStyleTrackers:
3358
def __init__(self):
3459
self.number = 0
3560
self.trackers = {}
@@ -39,6 +64,7 @@ def open(self, tracker_home):
3964
4065
Raise ValueError if the tracker home doesn't exist.
4166
'''
67+
import imp
4268
# sanity check existence of tracker home
4369
if not os.path.exists(tracker_home):
4470
raise ValueError, 'no such directory: "%s"'%tracker_home
@@ -67,11 +93,12 @@ def open(self, tracker_home):
6793

6894
return tracker
6995

70-
opener = Opener()
71-
open = opener.open
72-
73-
del Opener
74-
del opener
96+
OldStyleTrackers = OldStyleTrackers()
97+
def open(tracker_home):
98+
if os.path.exists(os.path.join(tracker_home, 'dbinit.py')):
99+
# user should upgrade...
100+
return OldStyleTrackers.open(tracker_home)
75101

102+
return Tracker(tracker_home)
76103

77104
# vim: set filetype=python ts=4 sw=4 et si

templates/classic/detectors/nosyreaction.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: nosyreaction.py,v 1.1 2003-04-17 03:26:38 richard Exp $
18+
#$Id: nosyreaction.py,v 1.1.2.1 2003-09-04 23:09:48 richard Exp $
1919

2020
from roundup import roundupdb, hyperdb
2121

@@ -107,8 +107,8 @@ def updatenosy(db, cl, nodeid, newvalues):
107107
else:
108108
ok = ('yes',)
109109
# figure which of the messages now on the issue weren't
110-
# there before - make sure we don't get a cached version!
111-
oldmessages = cl.get(nodeid, 'messages', cache=0)
110+
# there before
111+
oldmessages = cl.get(nodeid, 'messages')
112112
messages = []
113113
for msgid in newvalues['messages']:
114114
if msgid not in oldmessages:

templates/classic/detectors/statusauditor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020
#
21-
#$Id: statusauditor.py,v 1.2 2003-06-25 09:49:34 neaj Exp $
21+
#$Id: statusauditor.py,v 1.2.2.1 2003-09-04 23:09:48 richard Exp $
2222

2323
def chatty(db, cl, nodeid, newvalues):
2424
''' If the issue is currently 'unread', 'resolved' or 'done-cbb', then set
@@ -27,7 +27,7 @@ def chatty(db, cl, nodeid, newvalues):
2727
# don't fire if there's no new message (ie. chat)
2828
if not newvalues.has_key('messages'):
2929
return
30-
if newvalues['messages'] == cl.get(nodeid, 'messages', cache=0):
30+
if newvalues['messages'] == cl.get(nodeid, 'messages'):
3131
return
3232

3333
# get the chatting state ID

templates/classic/html/help_controls.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ function trim(value) {
5353

5454
function updateList() {
5555
// write back to opener window
56+
if (document.frm_help.check==undefined) { return; }
5657
var list = new Array();
5758
for (box=0; box < document.frm_help.check.length; box++) {
5859
if (document.frm_help.check[box].checked) {
@@ -64,6 +65,7 @@ function updateList() {
6465

6566
function updatePreview() {
6667
// add new checkbox selections to preview
68+
if (document.frm_help.check==undefined) { return; }
6769
var list = new Array();
6870
for (box=0; box < document.frm_help.check.length; box++) {
6971
if (document.frm_help.check[box].checked) {
@@ -76,13 +78,15 @@ function updatePreview() {
7678

7779
function clearList() {
7880
// uncheck all checkboxes
81+
if (document.frm_help.check==undefined) { return; }
7982
for (box=0; box < document.frm_help.check.length; box++) {
8083
document.frm_help.check[box].checked = false;
8184
}
8285
}
8386

8487
function reviseList(vals) {
8588
// update the checkboxes based on the preview field
89+
if (document.frm_help.check==undefined) { return; }
8690
var to_check;
8791
var list = vals.split(",");
8892
for (box=0; box < document.frm_help.check.length; box++) {
@@ -100,6 +104,7 @@ function reviseList(vals) {
100104

101105
function resetList() {
102106
// reset preview and check boxes to initial values
107+
if (document.frm_help.check==undefined) { return; }
103108
var to_check;
104109
var list = original_field.split(',');
105110
writePreview(list);

test/test_db.py

Lines changed: 9 additions & 2 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: test_db.py,v 1.90 2003-08-12 02:22:22 richard Exp $
18+
# $Id: test_db.py,v 1.90.2.1 2003-09-04 23:09:48 richard Exp $
1919

2020
import unittest, os, shutil, time
2121

@@ -296,7 +296,14 @@ def testRetire(self):
296296
self.assertNotEqual(a, self.db.status.list())
297297
# try to restore retired node
298298
self.db.status.restore('1')
299-
self.assertEqual(a, self.db.status.list())
299+
300+
def testCacheCreateSet(self):
301+
self.db.issue.create(title="spam", status='1')
302+
a = self.db.issue.get('1', 'title')
303+
self.assertEqual(a, 'spam')
304+
self.db.issue.set('1', title='ham')
305+
b = self.db.issue.get('1', 'title')
306+
self.assertEqual(b, 'ham')
300307

301308
def testSerialisation(self):
302309
nid = self.db.issue.create(title="spam", status='1',

0 commit comments

Comments
 (0)