Skip to content

Commit 3ca1b6d

Browse files
author
Richard Jones
committed
using isinstance(blah, Foo) now instead of isFooType
1 parent e4a410b commit 3ca1b6d

File tree

9 files changed

+140
-128
lines changed

9 files changed

+140
-128
lines changed

README.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ in general:
8686
. more unit tests
8787
. more back-ends
8888
. better error handling (nicer messages for users)
89-
. possibly revert the entire damn thing to 1.5.2 ... :(
9089
hyperdb:
9190
. transaction support
9291
. more efficient reverse lookups

roundup-admin

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: roundup-admin,v 1.15 2001-08-07 00:24:42 richard Exp $
19+
# $Id: roundup-admin,v 1.16 2001-08-12 06:32:36 richard Exp $
2020

2121
import sys
2222
if int(sys.version[0]) < 2:
@@ -174,15 +174,15 @@ def do_set(db, args):
174174
properties = cl.getprops()
175175
for key, value in props.items():
176176
type = properties[key]
177-
if type.isStringType:
177+
if isinstance(type, hyperdb.String):
178178
continue
179-
elif type.isDateType:
179+
elif isinstance(type, hyperdb.Date):
180180
props[key] = date.Date(value)
181-
elif type.isIntervalType:
181+
elif isinstance(type, hyperdb.Interval):
182182
props[key] = date.Interval(value)
183-
elif type.isLinkType:
183+
elif isinstance(type, hyperdb.Link):
184184
props[key] = value
185-
elif type.isMultilinkType:
185+
elif isinstance(type, hyperdb.Multilink):
186186
props[key] = value.split(',')
187187
apply(cl.set, (nodeid, ), props)
188188
return 0
@@ -238,15 +238,15 @@ def do_create(db, args):
238238
for prop in args[1:]:
239239
key, value = prop.split('=')
240240
type = properties[key]
241-
if type.isStringType:
241+
if isinstance(type, hyperdb.String):
242242
props[key] = value
243-
elif type.isDateType:
243+
elif isinstance(type, hyperdb.Date):
244244
props[key] = date.Date(value)
245-
elif type.isIntervalType:
245+
elif isinstance(type, hyperdb.Interval):
246246
props[key] = date.Interval(value)
247-
elif type.isLinkType:
247+
elif isinstance(type, hyperdb.Link):
248248
props[key] = value
249-
elif type.isMultilinkType:
249+
elif isinstance(type, hyperdb.Multilink):
250250
props[key] = value.split(',')
251251
print apply(cl.create, (), props)
252252
return 0
@@ -312,7 +312,7 @@ def do_freshen(db, args):
312312
# for nodeid in cl.list():
313313
# node = {}
314314
# for name, type in properties:
315-
# if type.isMultilinkType:
315+
# isinstance( if type, hyperdb.Multilink):
316316
# node[name] = cl.get(nodeid, name, [])
317317
# else:
318318
# node[name] = cl.get(nodeid, name, None)
@@ -422,6 +422,9 @@ if __name__ == '__main__':
422422

423423
#
424424
# $Log: not supported by cvs2svn $
425+
# Revision 1.15 2001/08/07 00:24:42 richard
426+
# stupid typo
427+
#
425428
# Revision 1.14 2001/08/07 00:15:51 richard
426429
# Added the copyright/license notice to (nearly) all files at request of
427430
# Bizar Software.

roundup/backends/back_anydbm.py

Lines changed: 8 additions & 5 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.6 2001-08-07 00:24:42 richard Exp $
18+
#$Id: back_anydbm.py,v 1.7 2001-08-12 06:32:36 richard Exp $
1919

2020
import anydbm, os, marshal
2121
from roundup import hyperdb, date
@@ -99,9 +99,9 @@ def addnode(self, classname, nodeid, node):
9999
# convert the instance data to builtin types
100100
properties = self.classes[classname].properties
101101
for key in properties.keys():
102-
if properties[key].isDateType:
102+
if isinstance(properties[key], hyperdb.Date):
103103
node[key] = node[key].get_tuple()
104-
elif properties[key].isIntervalType:
104+
elif isinstance(properties[key], hyperdb.Interval):
105105
node[key] = node[key].get_tuple()
106106

107107
# now save the marshalled data
@@ -121,9 +121,9 @@ def getnode(self, classname, nodeid, cldb=None):
121121
properties = self.classes[classname].properties
122122
for key in properties.keys():
123123
if key == self.RETIRED_FLAG: continue
124-
if properties[key].isDateType:
124+
if isinstance(properties[key], hyperdb.Date):
125125
res[key] = date.Date(res[key])
126-
elif properties[key].isIntervalType:
126+
elif isinstance(properties[key], hyperdb.Interval):
127127
res[key] = date.Interval(res[key])
128128

129129
if not cldb: db.close()
@@ -218,6 +218,9 @@ def rollback(self):
218218

219219
#
220220
#$Log: not supported by cvs2svn $
221+
#Revision 1.6 2001/08/07 00:24:42 richard
222+
#stupid typo
223+
#
221224
#Revision 1.5 2001/08/07 00:15:51 richard
222225
#Added the copyright/license notice to (nearly) all files at request of
223226
#Bizar Software.

roundup/backends/back_bsddb.py

Lines changed: 8 additions & 5 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_bsddb.py,v 1.8 2001-08-07 00:24:42 richard Exp $
18+
#$Id: back_bsddb.py,v 1.9 2001-08-12 06:32:36 richard Exp $
1919

2020
import bsddb, os, marshal
2121
from roundup import hyperdb, date
@@ -99,9 +99,9 @@ def addnode(self, classname, nodeid, node):
9999
# convert the instance data to builtin types
100100
properties = self.classes[classname].properties
101101
for key in properties.keys():
102-
if properties[key].isDateType:
102+
if isinstance(properties[key], hyperdb.Date):
103103
node[key] = node[key].get_tuple()
104-
elif properties[key].isIntervalType:
104+
elif isinstance(properties[key], hyperdb.Interval):
105105
node[key] = node[key].get_tuple()
106106

107107
# now save the marshalled data
@@ -120,9 +120,9 @@ def getnode(self, classname, nodeid, cldb=None):
120120
# convert the marshalled data to instances
121121
properties = self.classes[classname].properties
122122
for key in properties.keys():
123-
if properties[key].isDateType:
123+
if isinstance(properties[key], hyperdb.Date):
124124
res[key] = date.Date(res[key])
125-
elif properties[key].isIntervalType:
125+
elif isinstance(properties[key], hyperdb.Interval):
126126
res[key] = date.Interval(res[key])
127127

128128
if not cldb: db.close()
@@ -219,6 +219,9 @@ def rollback(self):
219219

220220
#
221221
#$Log: not supported by cvs2svn $
222+
#Revision 1.8 2001/08/07 00:24:42 richard
223+
#stupid typo
224+
#
222225
#Revision 1.7 2001/08/07 00:15:51 richard
223226
#Added the copyright/license notice to (nearly) all files at request of
224227
#Bizar Software.

roundup/backends/back_bsddb3.py

Lines changed: 8 additions & 5 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_bsddb3.py,v 1.6 2001-08-07 00:24:42 richard Exp $
18+
#$Id: back_bsddb3.py,v 1.7 2001-08-12 06:32:36 richard Exp $
1919

2020
import bsddb3, os, marshal
2121
from roundup import hyperdb, date
@@ -99,9 +99,9 @@ def addnode(self, classname, nodeid, node):
9999
# convert the instance data to builtin types
100100
properties = self.classes[classname].properties
101101
for key in properties.keys():
102-
if properties[key].isDateType:
102+
if isinstance(properties[key], hyperdb.Date):
103103
node[key] = node[key].get_tuple()
104-
elif properties[key].isIntervalType:
104+
elif isinstance(properties[key], hyperdb.Interval):
105105
node[key] = node[key].get_tuple()
106106

107107
# now save the marshalled data
@@ -120,9 +120,9 @@ def getnode(self, classname, nodeid, cldb=None):
120120
# convert the marshalled data to instances
121121
properties = self.classes[classname].properties
122122
for key in properties.keys():
123-
if properties[key].isDateType:
123+
if isinstance(properties[key], hyperdb.Date):
124124
res[key] = date.Date(res[key])
125-
elif properties[key].isIntervalType:
125+
elif isinstance(properties[key], hyperdb.Interval):
126126
res[key] = date.Interval(res[key])
127127

128128
if not cldb: db.close()
@@ -219,6 +219,9 @@ def rollback(self):
219219

220220
#
221221
#$Log: not supported by cvs2svn $
222+
#Revision 1.6 2001/08/07 00:24:42 richard
223+
#stupid typo
224+
#
222225
#Revision 1.5 2001/08/07 00:15:51 richard
223226
#Added the copyright/license notice to (nearly) all files at request of
224227
#Bizar Software.

roundup/cgi_client.py

Lines changed: 17 additions & 14 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: cgi_client.py,v 1.19 2001-08-07 00:24:42 richard Exp $
18+
# $Id: cgi_client.py,v 1.20 2001-08-12 06:32:36 richard Exp $
1919

2020
import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes
2121

@@ -124,7 +124,7 @@ def index_filterspec(self):
124124
if key[0] == ':': continue
125125
prop = props[key]
126126
value = self.form[key]
127-
if prop.isLinkType or prop.isMultilinkType:
127+
if isinstance(prop.isLinkType or prop, hyperdb.Multilink):
128128
if type(value) == type([]):
129129
value = [arg.value for arg in value]
130130
else:
@@ -205,13 +205,13 @@ def shownode(self, message=None):
205205
if not cl.properties.has_key(key):
206206
continue
207207
proptype = cl.properties[key]
208-
if proptype.isStringType:
208+
if isinstance(proptype, hyperdb.String):
209209
value = str(self.form[key].value).strip()
210-
elif proptype.isDateType:
210+
elif isinstance(proptype, hyperdb.Date):
211211
value = date.Date(str(self.form[key].value))
212-
elif proptype.isIntervalType:
212+
elif isinstance(proptype, hyperdb.Interval):
213213
value = date.Interval(str(self.form[key].value))
214-
elif proptype.isLinkType:
214+
elif isinstance(proptype, hyperdb.Link):
215215
value = str(self.form[key].value).strip()
216216
# handle key values
217217
link = cl.properties[key].classname
@@ -221,7 +221,7 @@ def shownode(self, message=None):
221221
except:
222222
raise ValueError, 'property "%s": %s not a %s'%(
223223
key, value, link)
224-
elif proptype.isMultilinkType:
224+
elif isinstance(proptype, hyperdb.Multilink):
225225
value = self.form[key]
226226
if type(value) != type([]):
227227
value = [i.strip() for i in str(value.value).split(',')]
@@ -299,13 +299,13 @@ def _createnode(self):
299299
if not cl.properties.has_key(key):
300300
continue
301301
proptype = cl.properties[key]
302-
if proptype.isStringType:
302+
if isinstance(proptype, hyperdb.String):
303303
value = self.form[key].value.strip()
304-
elif proptype.isDateType:
304+
elif isinstance(proptype, hyperdb.Date):
305305
value = date.Date(self.form[key].value.strip())
306-
elif proptype.isIntervalType:
306+
elif isinstance(proptype, hyperdb.Interval):
307307
value = date.Interval(self.form[key].value.strip())
308-
elif proptype.isLinkType:
308+
elif isinstance(proptype, hyperdb.Link):
309309
value = self.form[key].value.strip()
310310
# handle key values
311311
link = cl.properties[key].classname
@@ -315,7 +315,7 @@ def _createnode(self):
315315
except:
316316
raise ValueError, 'property "%s": %s not a %s'%(
317317
key, value, link)
318-
elif proptype.isMultilinkType:
318+
elif isinstance(proptype, hyperdb.Multilink):
319319
value = self.form[key]
320320
if type(value) != type([]):
321321
value = [i.strip() for i in value.value.split(',')]
@@ -402,14 +402,14 @@ def _post_editnode(self, nid, changes=None):
402402
m.append('\n-------')
403403
first = 0
404404
value = cl.get(nid, name, None)
405-
if prop.isLinkType:
405+
if isinstance(prop, hyperdb.Link):
406406
link = self.db.classes[prop.classname]
407407
key = link.labelprop(default_to_id=1)
408408
if value is not None and key:
409409
value = link.get(value, key)
410410
else:
411411
value = '-'
412-
elif prop.isMultilinkType:
412+
elif isinstance(prop, hyperdb.Multilink):
413413
if value is None: value = []
414414
l = []
415415
link = self.db.classes[prop.classname]
@@ -556,6 +556,9 @@ def __del__(self):
556556

557557
#
558558
# $Log: not supported by cvs2svn $
559+
# Revision 1.19 2001/08/07 00:24:42 richard
560+
# stupid typo
561+
#
559562
# Revision 1.18 2001/08/07 00:15:51 richard
560563
# Added the copyright/license notice to (nearly) all files at request of
561564
# Bizar Software.

0 commit comments

Comments
 (0)