From b998daa9fb3c2af443c78bc2310ac1f2c5f50ac8 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 12 Aug 2001 06:32:36 +0000 Subject: [PATCH] using isinstance(blah, Foo) now instead of isFooType git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@231 57a73879-2fb5-44c3-a270-3262357dd7e2 --- README.txt | 1 - roundup-admin | 27 +++++----- roundup/backends/back_anydbm.py | 13 +++-- roundup/backends/back_bsddb.py | 13 +++-- roundup/backends/back_bsddb3.py | 13 +++-- roundup/cgi_client.py | 31 ++++++----- roundup/htmltemplate.py | 59 ++++++++++---------- roundup/hyperdb.py | 96 +++++++++++++++------------------ roundup/mailgw.py | 15 +++--- 9 files changed, 140 insertions(+), 128 deletions(-) diff --git a/README.txt b/README.txt index ac9ee38..a15d3f9 100644 --- a/README.txt +++ b/README.txt @@ -86,7 +86,6 @@ in general: . more unit tests . more back-ends . better error handling (nicer messages for users) - . possibly revert the entire damn thing to 1.5.2 ... :( hyperdb: . transaction support . more efficient reverse lookups diff --git a/roundup-admin b/roundup-admin index a1be5c3..13b2047 100755 --- a/roundup-admin +++ b/roundup-admin @@ -16,7 +16,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundup-admin,v 1.15 2001-08-07 00:24:42 richard Exp $ +# $Id: roundup-admin,v 1.16 2001-08-12 06:32:36 richard Exp $ import sys if int(sys.version[0]) < 2: @@ -174,15 +174,15 @@ def do_set(db, args): properties = cl.getprops() for key, value in props.items(): type = properties[key] - if type.isStringType: + if isinstance(type, hyperdb.String): continue - elif type.isDateType: + elif isinstance(type, hyperdb.Date): props[key] = date.Date(value) - elif type.isIntervalType: + elif isinstance(type, hyperdb.Interval): props[key] = date.Interval(value) - elif type.isLinkType: + elif isinstance(type, hyperdb.Link): props[key] = value - elif type.isMultilinkType: + elif isinstance(type, hyperdb.Multilink): props[key] = value.split(',') apply(cl.set, (nodeid, ), props) return 0 @@ -238,15 +238,15 @@ def do_create(db, args): for prop in args[1:]: key, value = prop.split('=') type = properties[key] - if type.isStringType: + if isinstance(type, hyperdb.String): props[key] = value - elif type.isDateType: + elif isinstance(type, hyperdb.Date): props[key] = date.Date(value) - elif type.isIntervalType: + elif isinstance(type, hyperdb.Interval): props[key] = date.Interval(value) - elif type.isLinkType: + elif isinstance(type, hyperdb.Link): props[key] = value - elif type.isMultilinkType: + elif isinstance(type, hyperdb.Multilink): props[key] = value.split(',') print apply(cl.create, (), props) return 0 @@ -312,7 +312,7 @@ def do_freshen(db, args): # for nodeid in cl.list(): # node = {} # for name, type in properties: -# if type.isMultilinkType: +# isinstance( if type, hyperdb.Multilink): # node[name] = cl.get(nodeid, name, []) # else: # node[name] = cl.get(nodeid, name, None) @@ -422,6 +422,9 @@ if __name__ == '__main__': # # $Log: not supported by cvs2svn $ +# Revision 1.15 2001/08/07 00:24:42 richard +# stupid typo +# # Revision 1.14 2001/08/07 00:15:51 richard # Added the copyright/license notice to (nearly) all files at request of # Bizar Software. diff --git a/roundup/backends/back_anydbm.py b/roundup/backends/back_anydbm.py index 6176078..36fb3df 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.6 2001-08-07 00:24:42 richard Exp $ +#$Id: back_anydbm.py,v 1.7 2001-08-12 06:32:36 richard Exp $ import anydbm, os, marshal from roundup import hyperdb, date @@ -99,9 +99,9 @@ class Database(hyperdb.Database): # convert the instance data to builtin types properties = self.classes[classname].properties for key in properties.keys(): - if properties[key].isDateType: + if isinstance(properties[key], hyperdb.Date): node[key] = node[key].get_tuple() - elif properties[key].isIntervalType: + elif isinstance(properties[key], hyperdb.Interval): node[key] = node[key].get_tuple() # now save the marshalled data @@ -121,9 +121,9 @@ class Database(hyperdb.Database): properties = self.classes[classname].properties for key in properties.keys(): if key == self.RETIRED_FLAG: continue - if properties[key].isDateType: + if isinstance(properties[key], hyperdb.Date): res[key] = date.Date(res[key]) - elif properties[key].isIntervalType: + elif isinstance(properties[key], hyperdb.Interval): res[key] = date.Interval(res[key]) if not cldb: db.close() @@ -218,6 +218,9 @@ class Database(hyperdb.Database): # #$Log: not supported by cvs2svn $ +#Revision 1.6 2001/08/07 00:24:42 richard +#stupid typo +# #Revision 1.5 2001/08/07 00:15:51 richard #Added the copyright/license notice to (nearly) all files at request of #Bizar Software. diff --git a/roundup/backends/back_bsddb.py b/roundup/backends/back_bsddb.py index b5e25a2..4562d29 100644 --- a/roundup/backends/back_bsddb.py +++ b/roundup/backends/back_bsddb.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_bsddb.py,v 1.8 2001-08-07 00:24:42 richard Exp $ +#$Id: back_bsddb.py,v 1.9 2001-08-12 06:32:36 richard Exp $ import bsddb, os, marshal from roundup import hyperdb, date @@ -99,9 +99,9 @@ class Database(hyperdb.Database): # convert the instance data to builtin types properties = self.classes[classname].properties for key in properties.keys(): - if properties[key].isDateType: + if isinstance(properties[key], hyperdb.Date): node[key] = node[key].get_tuple() - elif properties[key].isIntervalType: + elif isinstance(properties[key], hyperdb.Interval): node[key] = node[key].get_tuple() # now save the marshalled data @@ -120,9 +120,9 @@ class Database(hyperdb.Database): # convert the marshalled data to instances properties = self.classes[classname].properties for key in properties.keys(): - if properties[key].isDateType: + if isinstance(properties[key], hyperdb.Date): res[key] = date.Date(res[key]) - elif properties[key].isIntervalType: + elif isinstance(properties[key], hyperdb.Interval): res[key] = date.Interval(res[key]) if not cldb: db.close() @@ -219,6 +219,9 @@ class Database(hyperdb.Database): # #$Log: not supported by cvs2svn $ +#Revision 1.8 2001/08/07 00:24:42 richard +#stupid typo +# #Revision 1.7 2001/08/07 00:15:51 richard #Added the copyright/license notice to (nearly) all files at request of #Bizar Software. diff --git a/roundup/backends/back_bsddb3.py b/roundup/backends/back_bsddb3.py index 46b693c..8c402e5 100644 --- a/roundup/backends/back_bsddb3.py +++ b/roundup/backends/back_bsddb3.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_bsddb3.py,v 1.6 2001-08-07 00:24:42 richard Exp $ +#$Id: back_bsddb3.py,v 1.7 2001-08-12 06:32:36 richard Exp $ import bsddb3, os, marshal from roundup import hyperdb, date @@ -99,9 +99,9 @@ class Database(hyperdb.Database): # convert the instance data to builtin types properties = self.classes[classname].properties for key in properties.keys(): - if properties[key].isDateType: + if isinstance(properties[key], hyperdb.Date): node[key] = node[key].get_tuple() - elif properties[key].isIntervalType: + elif isinstance(properties[key], hyperdb.Interval): node[key] = node[key].get_tuple() # now save the marshalled data @@ -120,9 +120,9 @@ class Database(hyperdb.Database): # convert the marshalled data to instances properties = self.classes[classname].properties for key in properties.keys(): - if properties[key].isDateType: + if isinstance(properties[key], hyperdb.Date): res[key] = date.Date(res[key]) - elif properties[key].isIntervalType: + elif isinstance(properties[key], hyperdb.Interval): res[key] = date.Interval(res[key]) if not cldb: db.close() @@ -219,6 +219,9 @@ class Database(hyperdb.Database): # #$Log: not supported by cvs2svn $ +#Revision 1.6 2001/08/07 00:24:42 richard +#stupid typo +# #Revision 1.5 2001/08/07 00:15:51 richard #Added the copyright/license notice to (nearly) all files at request of #Bizar Software. diff --git a/roundup/cgi_client.py b/roundup/cgi_client.py index c469882..4f43ab3 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.19 2001-08-07 00:24:42 richard Exp $ +# $Id: cgi_client.py,v 1.20 2001-08-12 06:32:36 richard Exp $ import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes @@ -124,7 +124,7 @@ class Client: if key[0] == ':': continue prop = props[key] value = self.form[key] - if prop.isLinkType or prop.isMultilinkType: + if isinstance(prop.isLinkType or prop, hyperdb.Multilink): if type(value) == type([]): value = [arg.value for arg in value] else: @@ -205,13 +205,13 @@ class Client: if not cl.properties.has_key(key): continue proptype = cl.properties[key] - if proptype.isStringType: + if isinstance(proptype, hyperdb.String): value = str(self.form[key].value).strip() - elif proptype.isDateType: + elif isinstance(proptype, hyperdb.Date): value = date.Date(str(self.form[key].value)) - elif proptype.isIntervalType: + elif isinstance(proptype, hyperdb.Interval): value = date.Interval(str(self.form[key].value)) - elif proptype.isLinkType: + elif isinstance(proptype, hyperdb.Link): value = str(self.form[key].value).strip() # handle key values link = cl.properties[key].classname @@ -221,7 +221,7 @@ class Client: except: raise ValueError, 'property "%s": %s not a %s'%( key, value, link) - elif proptype.isMultilinkType: + elif isinstance(proptype, hyperdb.Multilink): value = self.form[key] if type(value) != type([]): value = [i.strip() for i in str(value.value).split(',')] @@ -299,13 +299,13 @@ class Client: if not cl.properties.has_key(key): continue proptype = cl.properties[key] - if proptype.isStringType: + if isinstance(proptype, hyperdb.String): value = self.form[key].value.strip() - elif proptype.isDateType: + elif isinstance(proptype, hyperdb.Date): value = date.Date(self.form[key].value.strip()) - elif proptype.isIntervalType: + elif isinstance(proptype, hyperdb.Interval): value = date.Interval(self.form[key].value.strip()) - elif proptype.isLinkType: + elif isinstance(proptype, hyperdb.Link): value = self.form[key].value.strip() # handle key values link = cl.properties[key].classname @@ -315,7 +315,7 @@ class Client: except: raise ValueError, 'property "%s": %s not a %s'%( key, value, link) - elif proptype.isMultilinkType: + elif isinstance(proptype, hyperdb.Multilink): value = self.form[key] if type(value) != type([]): value = [i.strip() for i in value.value.split(',')] @@ -402,14 +402,14 @@ class Client: m.append('\n-------') first = 0 value = cl.get(nid, name, None) - if prop.isLinkType: + if isinstance(prop, hyperdb.Link): link = self.db.classes[prop.classname] key = link.labelprop(default_to_id=1) if value is not None and key: value = link.get(value, key) else: value = '-' - elif prop.isMultilinkType: + elif isinstance(prop, hyperdb.Multilink): if value is None: value = [] l = [] link = self.db.classes[prop.classname] @@ -556,6 +556,9 @@ class Client: # # $Log: not supported by cvs2svn $ +# Revision 1.19 2001/08/07 00:24:42 richard +# stupid typo +# # Revision 1.18 2001/08/07 00:15:51 richard # Added the copyright/license notice to (nearly) all files at request of # Bizar Software. diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index 68562ce..50ac79f 100644 --- a/roundup/htmltemplate.py +++ b/roundup/htmltemplate.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: htmltemplate.py,v 1.18 2001-08-07 00:24:42 richard Exp $ +# $Id: htmltemplate.py,v 1.19 2001-08-12 06:32:36 richard Exp $ import os, re, StringIO, urllib, cgi, errno @@ -48,21 +48,21 @@ class Plain(Base): value = self.cl.get(self.nodeid, property) else: # TODO: pull the value from the form - if propclass.isMultilinkType: value = [] + if isinstance(propclass, hyperdb.Multilink): value = [] else: value = '' - if propclass.isStringType: + if isinstance(propclass, hyperdb.String): if value is None: value = '' else: value = str(value) - elif propclass.isDateType: + elif isinstance(propclass, hyperdb.Date): value = str(value) - elif propclass.isIntervalType: + elif isinstance(propclass, hyperdb.Interval): value = str(value) - elif propclass.isLinkType: + elif isinstance(propclass, hyperdb.Link): linkcl = self.db.classes[propclass.classname] k = linkcl.labelprop() if value: value = str(linkcl.get(value, k)) else: value = '[unselected]' - elif propclass.isMultilinkType: + elif isinstance(propclass, hyperdb.Multilink): linkcl = self.db.classes[propclass.classname] k = linkcl.labelprop() value = ', '.join([linkcl.get(i, k) for i in value]) @@ -83,18 +83,18 @@ class Field(Base): # TODO: remove this from the code ... it's only here for # handling schema changes, and they should be handled outside # of this code... - if propclass.isMultilinkType and value is None: + if isinstance(propclass, hyperdb.Multilink) and value is None: value = [] elif self.filterspec is not None: - if propclass.isMultilinkType: + if isinstance(propclass, hyperdb.Multilink): value = self.filterspec.get(property, []) else: value = self.filterspec.get(property, '') else: # TODO: pull the value from the form - if propclass.isMultilinkType: value = [] + if isinstance(propclass, hyperdb.Multilink): value = [] else: value = '' - if (propclass.isStringType or propclass.isDateType or + if isinstance((propclass.isStringType or propclass, hyperdb.Date) or propclass.isIntervalType): size = size or 30 if value is None: @@ -103,7 +103,7 @@ class Field(Base): value = cgi.escape(value) value = '"'.join(value.split('"')) s = ''%(property, value, size) - elif propclass.isLinkType: + elif isinstance(propclass, hyperdb.Link): linkcl = self.db.classes[propclass.classname] l = ['') s = '\n'.join(l) - elif propclass.isMultilinkType: + elif isinstance(propclass, hyperdb.Multilink): linkcl = self.db.classes[propclass.classname] list = linkcl.list() height = height or min(len(list), 7) @@ -154,9 +154,9 @@ class Menu(Base): value = self.cl.get(self.nodeid, property) else: # TODO: pull the value from the form - if propclass.isMultilinkType: value = [] + if isinstance(propclass, hyperdb.Multilink): value = [] else: value = None - if propclass.isLinkType: + if isinstance(propclass, hyperdb.Link): linkcl = self.db.classes[propclass.classname] l = ['') return '\n'.join(l) - if propclass.isMultilinkType: + if isinstance(propclass, hyperdb.Multilink): linkcl = self.db.classes[propclass.classname] list = linkcl.list() height = height or min(len(list), 7) @@ -203,16 +203,16 @@ class Link(Base): if self.nodeid: value = self.cl.get(self.nodeid, property) else: - if propclass.isMultilinkType: value = [] + if isinstance(propclass, hyperdb.Multilink): value = [] else: value = '' - if propclass.isLinkType: + if isinstance(propclass, hyperdb.Link): if value is None: return '[not assigned]' linkcl = self.db.classes[propclass.classname] k = linkcl.labelprop() linkvalue = linkcl.get(value, k) return '%s'%(linkcl, value, linkvalue) - if propclass.isMultilinkType: + if isinstance(propclass, hyperdb.Multilink): linkcl = self.db.classes[propclass.classname] k = linkcl.labelprop() l = [] @@ -231,7 +231,7 @@ class Count(Base): return '[Count: not called from item]' propclass = self.properties[property] value = self.cl.get(self.nodeid, property) - if propclass.isMultilinkType: + if isinstance(propclass, hyperdb.Multilink): return str(len(value)) return '[Count: not a Multilink]' @@ -246,7 +246,7 @@ class Reldate(Base): if not self.nodeid and self.form is None: return '[Reldate: not called from item]' propclass = self.properties[property] - if not propclass.isDateType: + if isinstance(not propclass, hyperdb.Date): return '[Reldate: not a Date]' if self.nodeid: value = self.cl.get(self.nodeid, property) @@ -271,11 +271,11 @@ class Download(Base): return '[Download: not called from item]' propclass = self.properties[property] value = self.cl.get(self.nodeid, property) - if propclass.isLinkType: + if isinstance(propclass, hyperdb.Link): linkcl = self.db.classes[propclass.classname] linkvalue = linkcl.get(value, k) return '%s'%(linkcl, value, linkvalue) - if propclass.isMultilinkType: + if isinstance(propclass, hyperdb.Multilink): linkcl = self.db.classes[propclass.classname] l = [] for value in value: @@ -297,7 +297,7 @@ class Checklist(Base): value = self.filterspec.get(property, []) else: value = [] - if propclass.isLinkType or propclass.isMultilinkType: + if isinstance(propclass.isLinkType or propclass, hyperdb.Multilink): linkcl = self.db.classes[propclass.classname] l = [] k = linkcl.labelprop() @@ -328,7 +328,7 @@ class List(Base): ''' def __call__(self, property, **args): propclass = self.properties[property] - if not propclass.isMultilinkType: + if isinstance(not propclass, hyperdb.Multilink): return '[List: not a Multilink]' fp = StringIO.StringIO() args['show_display_form'] = 0 @@ -385,7 +385,7 @@ class IndexTemplateReplace: r'(([^>]+)">(?P.+?))|' r'(?P[^"]+)">))', re.I|re.S)): return replace.sub(self, text) - + def __call__(self, m, filter=None, columns=None, sort=None, group=None): if m.group('name'): if m.group('name') in self.props: @@ -536,7 +536,7 @@ def index(client, templates, db, classname, filterspec={}, filter=[], l = [] for name in group_names: prop = properties[name] - if prop.isLinkType: + if isinstance(prop, hyperdb.Link): group_cl = db.classes[prop.classname] key = group_cl.getkey() value = cl.get(nodeid, name) @@ -544,7 +544,7 @@ def index(client, templates, db, classname, filterspec={}, filter=[], l.append('[unselected %s]'%prop.classname) else: l.append(group_cl.get(cl.get(nodeid, name), key)) - elif prop.isMultilinkType: + elif isinstance(prop, hyperdb.Multilink): group_cl = db.classes[prop.classname] key = group_cl.getkey() for value in cl.get(nodeid, name): @@ -740,6 +740,9 @@ def newitem(client, templates, db, classname, form, replace=re.compile( # # $Log: not supported by cvs2svn $ +# Revision 1.18 2001/08/07 00:24:42 richard +# stupid typo +# # Revision 1.17 2001/08/07 00:15:51 richard # Added the copyright/license notice to (nearly) all files at request of # Bizar Software. diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py index c7033b1..eeb48b7 100644 --- a/roundup/hyperdb.py +++ b/roundup/hyperdb.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: hyperdb.py,v 1.14 2001-08-07 00:24:42 richard Exp $ +# $Id: hyperdb.py,v 1.15 2001-08-12 06:32:36 richard Exp $ # standard python modules import cPickle, re, string @@ -27,41 +27,37 @@ import date # # Types # -class BaseType: - isStringType = 0 - isDateType = 0 - isIntervalType = 0 - isLinkType = 0 - isMultilinkType = 0 - -class String(BaseType): - def __init__(self): - """An object designating a String property.""" - pass +class String: + """An object designating a String property.""" def __repr__(self): return '<%s>'%self.__class__ - isStringType = 1 -class Date(BaseType, String): - isDateType = 1 +class Date: + """An object designating a Date property.""" + def __repr__(self): + return '<%s>'%self.__class__ -class Interval(BaseType, String): - isIntervalType = 1 +class Interval: + """An object designating an Interval property.""" + def __repr__(self): + return '<%s>'%self.__class__ -class Link(BaseType): +class Link: + """An object designating a Link property that links to a + node in a specified class.""" def __init__(self, classname): - """An object designating a Link property that links to - nodes in a specified class.""" self.classname = classname def __repr__(self): return '<%s to "%s">'%(self.__class__, self.classname) - isLinkType = 1 -class Multilink(BaseType, Link): +class Multilink: """An object designating a Multilink property that links to nodes in a specified class. """ - isMultilinkType = 1 + def __init__(self, classname): + self.classname = classname + def __repr__(self): + return '<%s to "%s">'%(self.__class__, self.classname) class DatabaseError(ValueError): pass @@ -143,10 +139,9 @@ class Class: raise KeyError, '"%s" has no property "%s"'%(self.classname, key) - if prop.isLinkType: + if isinstance(prop, Link): if type(value) != type(''): raise ValueError, 'link value must be String' -# value = str(value) link_class = self.properties[key].classname # if it isn't a number, it's a key if not num_re.match(value): @@ -163,7 +158,7 @@ class Class: self.db.addjournal(link_class, value, 'link', (self.classname, newid, key)) - elif prop.isMultilinkType: + elif isinstance(prop, Multilink): if type(value) != type([]): raise TypeError, 'new property "%s" not a list of ids'%key link_class = self.properties[key].classname @@ -190,22 +185,22 @@ class Class: self.db.addjournal(link_class, id, 'link', (self.classname, newid, key)) - elif prop.isStringType: + elif isinstance(prop, String): if type(value) != type(''): raise TypeError, 'new property "%s" not a string'%key - elif prop.isDateType: + elif isinstance(prop, Date): if not hasattr(value, 'isDate'): raise TypeError, 'new property "%s" not a Date'% key - elif prop.isIntervalType: + elif isinstance(prop, Interval): if not hasattr(value, 'isInterval'): raise TypeError, 'new property "%s" not an Interval'% key for key, prop in self.properties.items(): if propvalues.has_key(key): continue - if prop.isMultilinkType: + if isinstance(prop, Multilink): propvalues[key] = [] else: propvalues[key] = None @@ -224,7 +219,6 @@ class Class: """ if propname == 'id': return nodeid -# nodeid = str(nodeid) d = self.db.getnode(self.classname, nodeid) if not d.has_key(propname) and default is not _marker: return default @@ -263,7 +257,6 @@ class Class: if self.db.journaltag is None: raise DatabaseError, 'Database open read-only' -# nodeid = str(nodeid) node = self.db.getnode(self.classname, nodeid) if node.has_key(self.db.RETIRED_FLAG): raise IndexError @@ -282,8 +275,7 @@ class Class: prop = self.properties[key] - if prop.isLinkType: -# value = str(value) + if isinstance(prop, Link): link_class = self.properties[key].classname # if it isn't a number, it's a key if type(value) != type(''): @@ -308,7 +300,7 @@ class Class: self.db.addjournal(link_class, value, 'link', (self.classname, nodeid, key)) - elif prop.isMultilinkType: + elif isinstance(prop, Multilink): if type(value) != type([]): raise TypeError, 'new property "%s" not a list of ids'%key link_class = self.properties[key].classname @@ -348,15 +340,15 @@ class Class: (self.classname, nodeid, key)) l.append(id) - elif prop.isStringType: + elif isinstance(prop, String): if value is not None and type(value) != type(''): raise TypeError, 'new property "%s" not a string'%key - elif prop.isDateType: + elif isinstance(prop, Date): if not hasattr(value, 'isDate'): raise TypeError, 'new property "%s" not a Date'% key - elif prop.isIntervalType: + elif isinstance(prop, Interval): if not hasattr(value, 'isInterval'): raise TypeError, 'new property "%s" not an Interval'% key @@ -374,7 +366,6 @@ class Class: Retired nodes are not returned by the find(), list(), or lookup() methods, and other nodes may reuse the values of their key properties. """ -# nodeid = str(nodeid) if self.db.journaltag is None: raise DatabaseError, 'Database open read-only' node = self.db.getnode(self.classname, nodeid) @@ -469,10 +460,9 @@ class Class: """ propspec = propspec.items() for propname, nodeid in propspec: -# nodeid = str(nodeid) # check the prop is OK prop = self.properties[propname] - if not prop.isLinkType and not prop.isMultilinkType: + if not isinstance(prop, Link) and not isinstance(prop, Multilink): raise TypeError, "'%s' not a Link/Multilink property"%propname if not self.db.hasnode(prop.classname, nodeid): raise ValueError, '%s has no node %s'%(link_class, nodeid) @@ -485,11 +475,10 @@ class Class: if node.has_key(self.db.RETIRED_FLAG): continue for propname, nodeid in propspec: -# nodeid = str(nodeid) property = node[propname] - if prop.isLinkType and nodeid == property: + if isinstance(prop, Link) and nodeid == property: l.append(id) - elif prop.isMultilinkType and nodeid in property: + elif isinstance(prop, Multilink) and nodeid in property: l.append(id) cldb.close() return l @@ -503,7 +492,7 @@ class Class: """ for propname in requirements.keys(): prop = self.properties[propname] - if not prop.isStringType: + if isinstance(not prop, String): raise TypeError, "'%s' not a String property"%propname l = [] cldb = self.db.getclassdb(self.classname) @@ -546,7 +535,7 @@ class Class: props = self.getprops() for k, v in filterspec.items(): propclass = props[k] - if propclass.isLinkType: + if isinstance(propclass, Link): if type(v) is not type([]): v = [v] # replace key values with node ids @@ -562,7 +551,7 @@ class Class: u.append(entry) l.append((0, k, u)) - elif propclass.isMultilinkType: + elif isinstance(propclass, Multilink): if type(v) is not type([]): v = [v] # replace key values with node ids @@ -577,7 +566,7 @@ class Class: k, entry, self.properties[k].classname) u.append(entry) l.append((1, k, u)) - elif propclass.isStringType: + elif isinstance(propclass, String): if '*' in v or '?' in v: # simple glob searching v = v.replace('?', '.') @@ -680,13 +669,13 @@ class Class: propclass = properties[prop] # String and Date values are sorted in the natural way - if propclass.isStringType: + if isinstance(propclass, String): # clean up the strings if av and av[0] in string.uppercase: av = an[prop] = av.lower() if bv and bv[0] in string.uppercase: bv = bn[prop] = bv.lower() - if propclass.isStringType or propclass.isDateType: + if isinstance(propclass.isStringType or propclass, Date): if dir == '+': r = cmp(av, bv) if r != 0: return r @@ -698,7 +687,7 @@ class Class: # the "order" property on the linked nodes if it is # present; or otherwise on the key string of the linked # nodes; or finally on the node ids. - elif propclass.isLinkType: + elif isinstance(propclass, Link): link = db.classes[propclass.classname] if av is None and bv is not None: return -1 if av is not None and bv is None: return 1 @@ -730,7 +719,7 @@ class Class: # Multilink properties are sorted according to how many # links are present. - elif propclass.isMultilinkType: + elif isinstance(propclass, Multilink): if dir == '+': r = cmp(len(av), len(bv)) if r != 0: return r @@ -817,6 +806,9 @@ def Choice(name, *options): # # $Log: not supported by cvs2svn $ +# Revision 1.14 2001/08/07 00:24:42 richard +# stupid typo +# # Revision 1.13 2001/08/07 00:15:51 richard # Added the copyright/license notice to (nearly) all files at request of # Bizar Software. diff --git a/roundup/mailgw.py b/roundup/mailgw.py index a9ff1aa..c8a3151 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -72,7 +72,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.12 2001-08-08 01:27:00 richard Exp $ +$Id: mailgw.py,v 1.13 2001-08-12 06:32:36 richard Exp $ ''' @@ -219,15 +219,15 @@ Subject argument list refers to an invalid property: "%s" Subject was: "%s" '''%(key, subject) - if type.isStringType: + if isinstance(type, hyperdb.String): props[key] = value - elif type.isDateType: + elif isinstance(type, hyperdb.Date): props[key] = date.Date(value) - elif type.isIntervalType: + elif isinstance(type, hyperdb.Interval): props[key] = date.Interval(value) - elif type.isLinkType: + elif isinstance(type, hyperdb.Link): props[key] = value - elif type.isMultilinkType: + elif isinstance(type, hyperdb.Multilink): props[key] = value.split(',') # handle the users @@ -398,6 +398,9 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'), # # $Log: not supported by cvs2svn $ +# Revision 1.12 2001/08/08 01:27:00 richard +# Added better error handling to mailgw. +# # Revision 1.11 2001/08/08 00:08:03 richard # oops ;) # -- 2.30.2