summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2faed99)
raw | patch | inline | side by side (parent: 2faed99)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 28 Feb 2003 03:33:46 +0000 (03:33 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 28 Feb 2003 03:33:46 +0000 (03:33 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1561 57a73879-2fb5-44c3-a270-3262357dd7e2
diff --git a/roundup/admin.py b/roundup/admin.py
index 8b90e46e083cdb246c999dfdaeb96fa7f9a93a3e..687797315566ddbe7f04a195f44fb4a2d4f8aee2 100644 (file)
--- a/roundup/admin.py
+++ b/roundup/admin.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: admin.py,v 1.39 2003-02-26 23:42:49 richard Exp $
+# $Id: admin.py,v 1.40 2003-02-28 03:33:46 richard Exp $
'''Administration commands for maintaining Roundup trackers.
'''
# all nodes for this class (not using list() 'cos it doesn't
# include retired nodes)
- for nodeid in self.db.getnodeids(classname):
+ for nodeid in self.db.getclass(classname).getnodeids():
# get the regular props
print >>f, p.join(cl.export_list(propnames, nodeid))
return 0
index dfacf2f48465a0aa76ab3800d683ff81e8194cb5..8a30e25334f6747d0b9c7e7b220d31bdb7520a5f 100644 (file)
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-#$Id: back_anydbm.py,v 1.106 2003-02-26 23:42:50 richard Exp $
+#$Id: back_anydbm.py,v 1.107 2003-02-28 03:33:46 richard Exp $
'''
This module defines a backend that saves the hyperdatabase in a database
chosen by anydbm. It is guaranteed to always be available in python
count = count + len(db.keys())
return count
- def getnodeids(self, classname, db=None):
- if __debug__:
- print >>hyperdb.DEBUG, 'getnodeids', (self, classname, db)
-
- res = []
-
- # start off with the new nodes
- if self.newnodes.has_key(classname):
- res += self.newnodes[classname].keys()
-
- if db is None:
- db = self.getclassdb(classname)
- res = res + db.keys()
-
- # remove the uncommitted, destroyed nodes
- if self.destroyednodes.has_key(classname):
- for nodeid in self.destroyednodes[classname].keys():
- if db.has_key(nodeid):
- res.remove(nodeid)
-
- return res
-
#
# Files - special node properties
raise TypeError, 'No key property set for class %s'%self.classname
cldb = self.db.getclassdb(self.classname)
try:
- for nodeid in self.db.getnodeids(self.classname, cldb):
+ for nodeid in self.getnodeids(cldb):
node = self.db.getnode(self.classname, nodeid, cldb)
if node.has_key(self.db.RETIRED_FLAG):
continue
cldb = self.db.getclassdb(self.classname)
l = []
try:
- for id in self.db.getnodeids(self.classname, db=cldb):
+ for id in self.getnodeids(db=cldb):
node = self.db.getnode(self.classname, id, db=cldb)
if node.has_key(self.db.RETIRED_FLAG):
continue
l = []
cldb = self.db.getclassdb(self.classname)
try:
- for nodeid in self.db.getnodeids(self.classname, cldb):
+ for nodeid in self.getnodeids(cldb):
node = self.db.getnode(self.classname, nodeid, cldb)
if node.has_key(self.db.RETIRED_FLAG):
continue
cn = self.classname
cldb = self.db.getclassdb(cn)
try:
- for nodeid in self.db.getnodeids(cn, cldb):
+ for nodeid in self.getnodeids(cldb):
node = self.db.getnode(cn, nodeid, cldb)
if node.has_key(self.db.RETIRED_FLAG):
continue
l.sort()
return l
+ def getnodeids(self, db=None):
+ ''' Return a list of ALL nodeids
+ '''
+ if __debug__:
+ print >>hyperdb.DEBUG, 'getnodeids', (self, self.classname, db)
+
+ res = []
+
+ # start off with the new nodes
+ if self.db.newnodes.has_key(classname):
+ res += self.db.newnodes[classname].keys()
+
+ if db is None:
+ db = self.db.getclassdb(classname)
+ res = res + db.keys()
+
+ # remove the uncommitted, destroyed nodes
+ if self.db.destroyednodes.has_key(classname):
+ for nodeid in self.db.destroyednodes[classname].keys():
+ if db.has_key(nodeid):
+ res.remove(nodeid)
+
+ return res
+
def filter(self, search_matches, filterspec, sort=(None,None),
group=(None,None), num_re = re.compile('^\d+$')):
''' Return a list of the ids of the active nodes in this class that
cldb = self.db.getclassdb(cn)
try:
# TODO: only full-scan once (use items())
- for nodeid in self.db.getnodeids(cn, cldb):
+ for nodeid in self.getnodeids(cldb):
node = self.db.getnode(cn, nodeid, cldb)
if node.has_key(self.db.RETIRED_FLAG):
continue
index 3cdcca87dfb1ad2440185fcfea6634cea37f0ccc..fd88d21df44dcdaf6de67fcb566a3e9265a8f327 100755 (executable)
try:
v = int(value)
except ValueError:
- raise TypeError, "%s (%s) is not numeric" % (key, repr(value))
+ raise TypeError, "%s (%s) is not numeric"%(key, repr(value))
setattr(row, key, v)
changes[key] = oldvalue
propvalues[key] = value
if value is None:
bv = 0
elif value not in (0,1):
- raise TypeError, "%s (%s) is not boolean" % (key, repr(value))
+ raise TypeError, "%s (%s) is not boolean"%(key, repr(value))
else:
bv = value
setattr(row, key, bv)
l.append(str(row.id))
return l
+ def getnodeids(self):
+ l = []
+ for row in self.getview():
+ l.append(str(row.id))
+ return l
+
def count(self):
return len(self.getview())
view = self.getview(1)
for i in range(len(propnames)):
value = eval(proplist[i])
+ if not value:
+ continue
propname = propnames[i]
prop = properties[propname]
if propname == 'id':
- newid = value
- value = int(value)
+ newid = value = int(value)
elif isinstance(prop, hyperdb.Date):
value = int(calendar.timegm(value))
elif isinstance(prop, hyperdb.Interval):
value = int(value)
elif isinstance(prop, hyperdb.Boolean):
value = int(value)
- elif isinstance(prop, hyperdb.Link):
+ elif isinstance(prop, hyperdb.Link) and value:
value = int(value)
elif isinstance(prop, hyperdb.Multilink):
- value = map(int, value)
+ # we handle multilinks separately
+ continue
d[propname] = value
# is the item retired?
if int(proplist[-1]):
d['_isdel'] = 1
- # XXX this is BROKEN for reasons I don't understand!
- ndx = view.append(d)
+ view.append(d)
+ ndx = view.find(id=newid)
+ row = view[ndx]
+ for i in range(len(propnames)):
+ value = eval(proplist[i])
+ propname = propnames[i]
+ prop = properties[propname]
+ if not isinstance(prop, hyperdb.Multilink):
+ continue
+ sv = getattr(row, propname)
+ for entry in value:
+ sv.append(int(entry))
+
+ self.db.dirty = 1
creator = d.get('creator', 0)
creation = d.get('creation', 0)
- self.db.addjournal(self.classname, newid, _CREATE, {}, creator,
+ self.db.addjournal(self.classname, str(newid), _CREATE, {}, creator,
creation)
return newid
index 375f12a5d0ada44f6e2634649c71723418a90918..55a400b285326a24885571b2277d80526a4fe107 100644 (file)
-# $Id: rdbms_common.py,v 1.37 2003-02-27 11:07:36 richard Exp $
+# $Id: rdbms_common.py,v 1.38 2003-02-28 03:33:46 richard Exp $
''' Relational database (SQL) backend common code.
Basics:
self.cursor.execute(sql)
return self.cursor.fetchone()[0]
- def getnodeids(self, classname, retired=0):
- ''' Retrieve all the ids of the nodes for a particular Class.
-
- Set retired=None to get all nodes. Otherwise it'll get all the
- retired or non-retired nodes, depending on the flag.
- '''
- # flip the sense of the flag if we don't want all of them
- if retired is not None:
- retired = not retired
- sql = 'select id from _%s where __retired__ <> %s'%(classname, self.arg)
- if __debug__:
- print >>hyperdb.DEBUG, 'getnodeids', (self, sql, retired)
- self.cursor.execute(sql, (retired,))
- return [x[0] for x in self.cursor.fetchall()]
-
def addjournal(self, classname, nodeid, action, params, creator=None,
creation=None):
''' Journal the Action
def list(self):
''' Return a list of the ids of the active nodes in this class.
'''
- return self.db.getnodeids(self.classname, retired=0)
+ return self.getnodeids(retired=0)
+
+ def getnodeids(self, retired=None):
+ ''' Retrieve all the ids of the nodes for a particular Class.
+
+ Set retired=None to get all nodes. Otherwise it'll get all the
+ retired or non-retired nodes, depending on the flag.
+ '''
+ # flip the sense of the flag if we don't want all of them
+ if retired is not None:
+ retired = not retired
+ sql = 'select id from _%s where __retired__ <> %s'%(self.classname,
+ self.db.arg)
+ if __debug__:
+ print >>hyperdb.DEBUG, 'getnodeids', (self, sql, retired)
+ self.db.cursor.execute(sql, (retired,))
+ return [x[0] for x in self.db.cursor.fetchall()]
def filter(self, search_matches, filterspec, sort=(None,None),
group=(None,None)):