Code

Optimize Class.find so that the propspec can contain a set of ids to match.
[roundup.git] / roundup / hyperdb.py
1 #
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
3 # This module is free software, and you may redistribute it and/or modify
4 # under the same terms as Python, so long as this copyright message and
5 # disclaimer are retained in their original form.
6 #
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
10 # POSSIBILITY OF SUCH DAMAGE.
11 #
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17
18 # $Id: hyperdb.py,v 1.72 2002-07-09 21:53:38 gmcm Exp $
20 __doc__ = """
21 Hyperdatabase implementation, especially field types.
22 """
24 # standard python modules
25 import sys, re, string, weakref, os, time
27 # roundup modules
28 import date, password
30 # configure up the DEBUG and TRACE captures
31 class Sink:
32     def write(self, content):
33         pass
34 DEBUG = os.environ.get('HYPERDBDEBUG', '')
35 if DEBUG and __debug__:
36     if DEBUG == 'stdout':
37         DEBUG = sys.stdout
38     else:
39         DEBUG = open(DEBUG, 'a')
40 else:
41     DEBUG = Sink()
42 TRACE = os.environ.get('HYPERDBTRACE', '')
43 if TRACE and __debug__:
44     if TRACE == 'stdout':
45         TRACE = sys.stdout
46     else:
47         TRACE = open(TRACE, 'w')
48 else:
49     TRACE = Sink()
50 def traceMark():
51     print >>TRACE, '**MARK', time.ctime()
52 del Sink
54 #
55 # Types
56 #
57 class String:
58     """An object designating a String property."""
59     def __init__(self, indexme='no'):
60         self.indexme = indexme == 'yes'
61     def __repr__(self):
62         ' more useful for dumps '
63         return '<%s>'%self.__class__
65 class Password:
66     """An object designating a Password property."""
67     def __repr__(self):
68         ' more useful for dumps '
69         return '<%s>'%self.__class__
71 class Date:
72     """An object designating a Date property."""
73     def __repr__(self):
74         ' more useful for dumps '
75         return '<%s>'%self.__class__
77 class Interval:
78     """An object designating an Interval property."""
79     def __repr__(self):
80         ' more useful for dumps '
81         return '<%s>'%self.__class__
83 class Link:
84     """An object designating a Link property that links to a
85        node in a specified class."""
86     def __init__(self, classname, do_journal='no'):
87         ''' Default is to not journal link and unlink events
88         '''
89         self.classname = classname
90         self.do_journal = do_journal == 'yes'
91     def __repr__(self):
92         ' more useful for dumps '
93         return '<%s to "%s">'%(self.__class__, self.classname)
95 class Multilink:
96     """An object designating a Multilink property that links
97        to nodes in a specified class.
99        "classname" indicates the class to link to
101        "do_journal" indicates whether the linked-to nodes should have
102                     'link' and 'unlink' events placed in their journal
103     """
104     def __init__(self, classname, do_journal='no'):
105         ''' Default is to not journal link and unlink events
106         '''
107         self.classname = classname
108         self.do_journal = do_journal == 'yes'
109     def __repr__(self):
110         ' more useful for dumps '
111         return '<%s to "%s">'%(self.__class__, self.classname)
113 class DatabaseError(ValueError):
114     '''Error to be raised when there is some problem in the database code
115     '''
116     pass
120 # the base Database class
122 class Database:
123     '''A database for storing records containing flexible data types.
125 This class defines a hyperdatabase storage layer, which the Classes use to
126 store their data.
129 Transactions
130 ------------
131 The Database should support transactions through the commit() and
132 rollback() methods. All other Database methods should be transaction-aware,
133 using data from the current transaction before looking up the database.
135 An implementation must provide an override for the get() method so that the
136 in-database value is returned in preference to the in-transaction value.
137 This is necessary to determine if any values have changed during a
138 transaction.
140 '''
142     # flag to set on retired entries
143     RETIRED_FLAG = '__hyperdb_retired'
145     # XXX deviates from spec: storagelocator is obtained from the config
146     def __init__(self, config, journaltag=None):
147         """Open a hyperdatabase given a specifier to some storage.
149         The 'storagelocator' is obtained from config.DATABASE.
150         The meaning of 'storagelocator' depends on the particular
151         implementation of the hyperdatabase.  It could be a file name,
152         a directory path, a socket descriptor for a connection to a
153         database over the network, etc.
155         The 'journaltag' is a token that will be attached to the journal
156         entries for any edits done on the database.  If 'journaltag' is
157         None, the database is opened in read-only mode: the Class.create(),
158         Class.set(), and Class.retire() methods are disabled.
159         """
160         raise NotImplementedError
162     def post_init(self):
163         """Called once the schema initialisation has finished."""
164         raise NotImplementedError
166     def __getattr__(self, classname):
167         """A convenient way of calling self.getclass(classname)."""
168         raise NotImplementedError
170     def addclass(self, cl):
171         '''Add a Class to the hyperdatabase.
172         '''
173         raise NotImplementedError
175     def getclasses(self):
176         """Return a list of the names of all existing classes."""
177         raise NotImplementedError
179     def getclass(self, classname):
180         """Get the Class object representing a particular class.
182         If 'classname' is not a valid class name, a KeyError is raised.
183         """
184         raise NotImplementedError
186     def clear(self):
187         '''Delete all database contents.
188         '''
189         raise NotImplementedError
191     def getclassdb(self, classname, mode='r'):
192         '''Obtain a connection to the class db that will be used for
193            multiple actions.
194         '''
195         raise NotImplementedError
197     def addnode(self, classname, nodeid, node):
198         '''Add the specified node to its class's db.
199         '''
200         raise NotImplementedError
202     def serialise(self, classname, node):
203         '''Copy the node contents, converting non-marshallable data into
204            marshallable data.
205         '''
206         if __debug__:
207             print >>DEBUG, 'serialise', classname, node
208         properties = self.getclass(classname).getprops()
209         d = {}
210         for k, v in node.items():
211             # if the property doesn't exist, or is the "retired" flag then
212             # it won't be in the properties dict
213             if not properties.has_key(k):
214                 d[k] = v
215                 continue
217             # get the property spec
218             prop = properties[k]
220             if isinstance(prop, Password):
221                 d[k] = str(v)
222             elif isinstance(prop, Date) and v is not None:
223                 d[k] = v.get_tuple()
224             elif isinstance(prop, Interval) and v is not None:
225                 d[k] = v.get_tuple()
226             else:
227                 d[k] = v
228         return d
230     def setnode(self, classname, nodeid, node):
231         '''Change the specified node.
232         '''
233         raise NotImplementedError
235     def unserialise(self, classname, node):
236         '''Decode the marshalled node data
237         '''
238         if __debug__:
239             print >>DEBUG, 'unserialise', classname, node
240         properties = self.getclass(classname).getprops()
241         d = {}
242         for k, v in node.items():
243             # if the property doesn't exist, or is the "retired" flag then
244             # it won't be in the properties dict
245             if not properties.has_key(k):
246                 d[k] = v
247                 continue
249             # get the property spec
250             prop = properties[k]
252             if isinstance(prop, Date) and v is not None:
253                 d[k] = date.Date(v)
254             elif isinstance(prop, Interval) and v is not None:
255                 d[k] = date.Interval(v)
256             elif isinstance(prop, Password):
257                 p = password.Password()
258                 p.unpack(v)
259                 d[k] = p
260             else:
261                 d[k] = v
262         return d
264     def getnode(self, classname, nodeid, db=None, cache=1):
265         '''Get a node from the database.
266         '''
267         raise NotImplementedError
269     def hasnode(self, classname, nodeid, db=None):
270         '''Determine if the database has a given node.
271         '''
272         raise NotImplementedError
274     def countnodes(self, classname, db=None):
275         '''Count the number of nodes that exist for a particular Class.
276         '''
277         raise NotImplementedError
279     def getnodeids(self, classname, db=None):
280         '''Retrieve all the ids of the nodes for a particular Class.
281         '''
282         raise NotImplementedError
284     def storefile(self, classname, nodeid, property, content):
285         '''Store the content of the file in the database.
286         
287            The property may be None, in which case the filename does not
288            indicate which property is being saved.
289         '''
290         raise NotImplementedError
292     def getfile(self, classname, nodeid, property):
293         '''Store the content of the file in the database.
294         '''
295         raise NotImplementedError
297     def addjournal(self, classname, nodeid, action, params):
298         ''' Journal the Action
299         'action' may be:
301             'create' or 'set' -- 'params' is a dictionary of property values
302             'link' or 'unlink' -- 'params' is (classname, nodeid, propname)
303             'retire' -- 'params' is None
304         '''
305         raise NotImplementedError
307     def getjournal(self, classname, nodeid):
308         ''' get the journal for id
309         '''
310         raise NotImplementedError
312     def pack(self, pack_before):
313         ''' pack the database
314         '''
315         raise NotImplementedError
317     def commit(self):
318         ''' Commit the current transactions.
320         Save all data changed since the database was opened or since the
321         last commit() or rollback().
322         '''
323         raise NotImplementedError
325     def rollback(self):
326         ''' Reverse all actions from the current transaction.
328         Undo all the changes made since the database was opened or the last
329         commit() or rollback() was performed.
330         '''
331         raise NotImplementedError
333 _marker = []
335 # The base Class class
337 class Class:
338     """The handle to a particular class of nodes in a hyperdatabase."""
340     def __init__(self, db, classname, **properties):
341         """Create a new class with a given name and property specification.
343         'classname' must not collide with the name of an existing class,
344         or a ValueError is raised.  The keyword arguments in 'properties'
345         must map names to property objects, or a TypeError is raised.
346         """
347         self.classname = classname
348         self.properties = properties
349         self.db = weakref.proxy(db)       # use a weak ref to avoid circularity
350         self.key = ''
352         # do the db-related init stuff
353         db.addclass(self)
355     def __repr__(self):
356         '''Slightly more useful representation
357         '''
358         return '<hypderdb.Class "%s">'%self.classname
360     # Editing nodes:
362     def create(self, **propvalues):
363         """Create a new node of this class and return its id.
365         The keyword arguments in 'propvalues' map property names to values.
367         The values of arguments must be acceptable for the types of their
368         corresponding properties or a TypeError is raised.
369         
370         If this class has a key property, it must be present and its value
371         must not collide with other key strings or a ValueError is raised.
372         
373         Any other properties on this class that are missing from the
374         'propvalues' dictionary are set to None.
375         
376         If an id in a link or multilink property does not refer to a valid
377         node, an IndexError is raised.
378         """
379         if propvalues.has_key('id'):
380             raise KeyError, '"id" is reserved'
382         if self.db.journaltag is None:
383             raise DatabaseError, 'Database open read-only'
385         # new node's id
386         newid = self.db.newid(self.classname)
388         # validate propvalues
389         num_re = re.compile('^\d+$')
390         for key, value in propvalues.items():
391             if key == self.key:
392                 try:
393                     self.lookup(value)
394                 except KeyError:
395                     pass
396                 else:
397                     raise ValueError, 'node with key "%s" exists'%value
399             # try to handle this property
400             try:
401                 prop = self.properties[key]
402             except KeyError:
403                 raise KeyError, '"%s" has no property "%s"'%(self.classname,
404                     key)
406             if isinstance(prop, Link):
407                 if type(value) != type(''):
408                     raise ValueError, 'link value must be String'
409                 link_class = self.properties[key].classname
410                 # if it isn't a number, it's a key
411                 if not num_re.match(value):
412                     try:
413                         value = self.db.classes[link_class].lookup(value)
414                     except (TypeError, KeyError):
415                         raise IndexError, 'new property "%s": %s not a %s'%(
416                             key, value, link_class)
417                 elif not self.db.hasnode(link_class, value):
418                     raise IndexError, '%s has no node %s'%(link_class, value)
420                 # save off the value
421                 propvalues[key] = value
423                 # register the link with the newly linked node
424                 if self.properties[key].do_journal:
425                     self.db.addjournal(link_class, value, 'link',
426                         (self.classname, newid, key))
428             elif isinstance(prop, Multilink):
429                 if type(value) != type([]):
430                     raise TypeError, 'new property "%s" not a list of ids'%key
432                 # clean up and validate the list of links
433                 link_class = self.properties[key].classname
434                 l = []
435                 for entry in value:
436                     if type(entry) != type(''):
437                         raise ValueError, '"%s" link value (%s) must be String' % (key, value)
438                     # if it isn't a number, it's a key
439                     if not num_re.match(entry):
440                         try:
441                             entry = self.db.classes[link_class].lookup(entry)
442                         except (TypeError, KeyError):
443                             raise IndexError, 'new property "%s": %s not a %s'%(
444                                 key, entry, self.properties[key].classname)
445                     l.append(entry)
446                 value = l
447                 propvalues[key] = value
449                 # handle additions
450                 for id in value:
451                     if not self.db.hasnode(link_class, id):
452                         raise IndexError, '%s has no node %s'%(link_class, id)
453                     # register the link with the newly linked node
454                     if self.properties[key].do_journal:
455                         self.db.addjournal(link_class, id, 'link',
456                             (self.classname, newid, key))
458             elif isinstance(prop, String):
459                 if type(value) != type(''):
460                     raise TypeError, 'new property "%s" not a string'%key
462             elif isinstance(prop, Password):
463                 if not isinstance(value, password.Password):
464                     raise TypeError, 'new property "%s" not a Password'%key
466             elif isinstance(prop, Date):
467                 if value is not None and not isinstance(value, date.Date):
468                     raise TypeError, 'new property "%s" not a Date'%key
470             elif isinstance(prop, Interval):
471                 if value is not None and not isinstance(value, date.Interval):
472                     raise TypeError, 'new property "%s" not an Interval'%key
474         # make sure there's data where there needs to be
475         for key, prop in self.properties.items():
476             if propvalues.has_key(key):
477                 continue
478             if key == self.key:
479                 raise ValueError, 'key property "%s" is required'%key
480             if isinstance(prop, Multilink):
481                 propvalues[key] = []
482             else:
483                 # TODO: None isn't right here, I think...
484                 propvalues[key] = None
486         # done
487         self.db.addnode(self.classname, newid, propvalues)
488         self.db.addjournal(self.classname, newid, 'create', propvalues)
489         return newid
491     def get(self, nodeid, propname, default=_marker, cache=1):
492         """Get the value of a property on an existing node of this class.
494         'nodeid' must be the id of an existing node of this class or an
495         IndexError is raised.  'propname' must be the name of a property
496         of this class or a KeyError is raised.
498         'cache' indicates whether the transaction cache should be queried
499         for the node. If the node has been modified and you need to
500         determine what its values prior to modification are, you need to
501         set cache=0.
502         """
503         if propname == 'id':
504             return nodeid
506         # get the property (raises KeyErorr if invalid)
507         prop = self.properties[propname]
509         # get the node's dict
510         d = self.db.getnode(self.classname, nodeid, cache=cache)
512         if not d.has_key(propname):
513             if default is _marker:
514                 if isinstance(prop, Multilink):
515                     return []
516                 else:
517                     # TODO: None isn't right here, I think...
518                     return None
519             else:
520                 return default
522         return d[propname]
524     # XXX not in spec
525     def getnode(self, nodeid, cache=1):
526         ''' Return a convenience wrapper for the node.
528         'nodeid' must be the id of an existing node of this class or an
529         IndexError is raised.
531         'cache' indicates whether the transaction cache should be queried
532         for the node. If the node has been modified and you need to
533         determine what its values prior to modification are, you need to
534         set cache=0.
535         '''
536         return Node(self, nodeid, cache=cache)
538     def set(self, nodeid, **propvalues):
539         """Modify a property on an existing node of this class.
540         
541         'nodeid' must be the id of an existing node of this class or an
542         IndexError is raised.
544         Each key in 'propvalues' must be the name of a property of this
545         class or a KeyError is raised.
547         All values in 'propvalues' must be acceptable types for their
548         corresponding properties or a TypeError is raised.
550         If the value of the key property is set, it must not collide with
551         other key strings or a ValueError is raised.
553         If the value of a Link or Multilink property contains an invalid
554         node id, a ValueError is raised.
555         """
556         if not propvalues:
557             return
559         if propvalues.has_key('id'):
560             raise KeyError, '"id" is reserved'
562         if self.db.journaltag is None:
563             raise DatabaseError, 'Database open read-only'
565         node = self.db.getnode(self.classname, nodeid)
566         if node.has_key(self.db.RETIRED_FLAG):
567             raise IndexError
568         num_re = re.compile('^\d+$')
569         for key, value in propvalues.items():
570             # check to make sure we're not duplicating an existing key
571             if key == self.key and node[key] != value:
572                 try:
573                     self.lookup(value)
574                 except KeyError:
575                     pass
576                 else:
577                     raise ValueError, 'node with key "%s" exists'%value
579             # this will raise the KeyError if the property isn't valid
580             # ... we don't use getprops() here because we only care about
581             # the writeable properties.
582             prop = self.properties[key]
584             # if the value's the same as the existing value, no sense in
585             # doing anything
586             if node.has_key(key) and value == node[key]:
587                 del propvalues[key]
588                 continue
590             # do stuff based on the prop type
591             if isinstance(prop, Link):
592                 link_class = self.properties[key].classname
593                 # if it isn't a number, it's a key
594                 if type(value) != type(''):
595                     raise ValueError, 'link value must be String'
596                 if not num_re.match(value):
597                     try:
598                         value = self.db.classes[link_class].lookup(value)
599                     except (TypeError, KeyError):
600                         raise IndexError, 'new property "%s": %s not a %s'%(
601                             key, value, self.properties[key].classname)
603                 if not self.db.hasnode(link_class, value):
604                     raise IndexError, '%s has no node %s'%(link_class, value)
606                 if self.properties[key].do_journal:
607                     # register the unlink with the old linked node
608                     if node[key] is not None:
609                         self.db.addjournal(link_class, node[key], 'unlink',
610                             (self.classname, nodeid, key))
612                     # register the link with the newly linked node
613                     if value is not None:
614                         self.db.addjournal(link_class, value, 'link',
615                             (self.classname, nodeid, key))
617             elif isinstance(prop, Multilink):
618                 if type(value) != type([]):
619                     raise TypeError, 'new property "%s" not a list of ids'%key
620                 link_class = self.properties[key].classname
621                 l = []
622                 for entry in value:
623                     # if it isn't a number, it's a key
624                     if type(entry) != type(''):
625                         raise ValueError, 'new property "%s" link value ' \
626                             'must be a string'%key
627                     if not num_re.match(entry):
628                         try:
629                             entry = self.db.classes[link_class].lookup(entry)
630                         except (TypeError, KeyError):
631                             raise IndexError, 'new property "%s": %s not a %s'%(
632                                 key, entry, self.properties[key].classname)
633                     l.append(entry)
634                 value = l
635                 propvalues[key] = value
637                 # handle removals
638                 if node.has_key(key):
639                     l = node[key]
640                 else:
641                     l = []
642                 for id in l[:]:
643                     if id in value:
644                         continue
645                     # register the unlink with the old linked node
646                     if self.properties[key].do_journal:
647                         self.db.addjournal(link_class, id, 'unlink',
648                             (self.classname, nodeid, key))
649                     l.remove(id)
651                 # handle additions
652                 for id in value:
653                     if not self.db.hasnode(link_class, id):
654                         raise IndexError, '%s has no node %s'%(
655                             link_class, id)
656                     if id in l:
657                         continue
658                     # register the link with the newly linked node
659                     if self.properties[key].do_journal:
660                         self.db.addjournal(link_class, id, 'link',
661                             (self.classname, nodeid, key))
662                     l.append(id)
664             elif isinstance(prop, String):
665                 if value is not None and type(value) != type(''):
666                     raise TypeError, 'new property "%s" not a string'%key
668             elif isinstance(prop, Password):
669                 if not isinstance(value, password.Password):
670                     raise TypeError, 'new property "%s" not a Password'% key
671                 propvalues[key] = value
673             elif value is not None and isinstance(prop, Date):
674                 if not isinstance(value, date.Date):
675                     raise TypeError, 'new property "%s" not a Date'% key
676                 propvalues[key] = value
678             elif value is not None and isinstance(prop, Interval):
679                 if not isinstance(value, date.Interval):
680                     raise TypeError, 'new property "%s" not an Interval'% key
681                 propvalues[key] = value
683             node[key] = value
685         # nothing to do?
686         if not propvalues:
687             return
689         # do the set, and journal it
690         self.db.setnode(self.classname, nodeid, node)
691         self.db.addjournal(self.classname, nodeid, 'set', propvalues)
693     def retire(self, nodeid):
694         """Retire a node.
695         
696         The properties on the node remain available from the get() method,
697         and the node's id is never reused.
698         
699         Retired nodes are not returned by the find(), list(), or lookup()
700         methods, and other nodes may reuse the values of their key properties.
701         """
702         if self.db.journaltag is None:
703             raise DatabaseError, 'Database open read-only'
704         node = self.db.getnode(self.classname, nodeid)
705         node[self.db.RETIRED_FLAG] = 1
706         self.db.setnode(self.classname, nodeid, node)
707         self.db.addjournal(self.classname, nodeid, 'retired', None)
709     def history(self, nodeid):
710         """Retrieve the journal of edits on a particular node.
712         'nodeid' must be the id of an existing node of this class or an
713         IndexError is raised.
715         The returned list contains tuples of the form
717             (date, tag, action, params)
719         'date' is a Timestamp object specifying the time of the change and
720         'tag' is the journaltag specified when the database was opened.
721         """
722         return self.db.getjournal(self.classname, nodeid)
724     # Locating nodes:
725     def hasnode(self, nodeid):
726         '''Determine if the given nodeid actually exists
727         '''
728         return self.db.hasnode(self.classname, nodeid)
730     def setkey(self, propname):
731         """Select a String property of this class to be the key property.
733         'propname' must be the name of a String property of this class or
734         None, or a TypeError is raised.  The values of the key property on
735         all existing nodes must be unique or a ValueError is raised.
736         """
737         # TODO: validate that the property is a String!
738         self.key = propname
740     def getkey(self):
741         """Return the name of the key property for this class or None."""
742         return self.key
744     def labelprop(self, default_to_id=0):
745         ''' Return the property name for a label for the given node.
747         This method attempts to generate a consistent label for the node.
748         It tries the following in order:
749             1. key property
750             2. "name" property
751             3. "title" property
752             4. first property from the sorted property name list
753         '''
754         k = self.getkey()
755         if  k:
756             return k
757         props = self.getprops()
758         if props.has_key('name'):
759             return 'name'
760         elif props.has_key('title'):
761             return 'title'
762         if default_to_id:
763             return 'id'
764         props = props.keys()
765         props.sort()
766         return props[0]
768     # TODO: set up a separate index db file for this? profile?
769     def lookup(self, keyvalue):
770         """Locate a particular node by its key property and return its id.
772         If this class has no key property, a TypeError is raised.  If the
773         'keyvalue' matches one of the values for the key property among
774         the nodes in this class, the matching node's id is returned;
775         otherwise a KeyError is raised.
776         """
777         cldb = self.db.getclassdb(self.classname)
778         for nodeid in self.db.getnodeids(self.classname, cldb):
779             node = self.db.getnode(self.classname, nodeid, cldb)
780             if node.has_key(self.db.RETIRED_FLAG):
781                 continue
782             if node[self.key] == keyvalue:
783                 return nodeid
784         raise KeyError, keyvalue
786     # XXX: change from spec - allows multiple props to match
787     def find(self, **propspec):
788         """Get the ids of nodes in this class which link to the given nodes.
790         'propspec' consists of keyword args propname={nodeid:1,}   
791           'propname' must be the name of a property in this class, or a
792             KeyError is raised.  That property must be a Link or Multilink
793             property, or a TypeError is raised.
795         Any node in this class whose 'propname' property links to any of the
796         nodeids will be returned. Used by the full text indexing, which knows
797         that "foo" occurs in msg1, msg3 and file7, so we have hits on these issues:
798             db.issue.find(messages={'1':1,'3':1}, files={'7':1})
799         """
800         propspec = propspec.items()
801         for propname, nodeids in propspec:
802             # check the prop is OK
803             prop = self.properties[propname]
804             if not isinstance(prop, Link) and not isinstance(prop, Multilink):
805                 raise TypeError, "'%s' not a Link/Multilink property"%propname
806             #XXX edit is expensive and of questionable use
807             #for nodeid in nodeids:
808             #    if not self.db.hasnode(prop.classname, nodeid):
809             #        raise ValueError, '%s has no node %s'%(prop.classname, nodeid)
811         # ok, now do the find
812         cldb = self.db.getclassdb(self.classname)
813         l = []
814         for id in self.db.getnodeids(self.classname, db=cldb):
815             node = self.db.getnode(self.classname, id, db=cldb)
816             if node.has_key(self.db.RETIRED_FLAG):
817                 continue
818             for propname, nodeids in propspec:
819                 # can't test if the node doesn't have this property
820                 if not node.has_key(propname):
821                     continue
822                 if type(nodeids) is type(''):
823                     nodeids = {nodeids:1}
824                 prop = self.properties[propname]
825                 value = node[propname]
826                 if isinstance(prop, Link) and nodeids.has_key(value):
827                     l.append(id)
828                     break
829                 elif isinstance(prop, Multilink):
830                     hit = 0
831                     for v in value:
832                         if nodeids.has_key(v):
833                             l.append(id)
834                             hit = 1
835                             break
836                     if hit:
837                         break
838         return l
840     def stringFind(self, **requirements):
841         """Locate a particular node by matching a set of its String
842         properties in a caseless search.
844         If the property is not a String property, a TypeError is raised.
845         
846         The return is a list of the id of all nodes that match.
847         """
848         for propname in requirements.keys():
849             prop = self.properties[propname]
850             if isinstance(not prop, String):
851                 raise TypeError, "'%s' not a String property"%propname
852             requirements[propname] = requirements[propname].lower()
853         l = []
854         cldb = self.db.getclassdb(self.classname)
855         for nodeid in self.db.getnodeids(self.classname, cldb):
856             node = self.db.getnode(self.classname, nodeid, cldb)
857             if node.has_key(self.db.RETIRED_FLAG):
858                 continue
859             for key, value in requirements.items():
860                 if node[key] and node[key].lower() != value:
861                     break
862             else:
863                 l.append(nodeid)
864         return l
866     def list(self):
867         """Return a list of the ids of the active nodes in this class."""
868         l = []
869         cn = self.classname
870         cldb = self.db.getclassdb(cn)
871         for nodeid in self.db.getnodeids(cn, cldb):
872             node = self.db.getnode(cn, nodeid, cldb)
873             if node.has_key(self.db.RETIRED_FLAG):
874                 continue
875             l.append(nodeid)
876         l.sort()
877         return l
879     # XXX not in spec
880     def filter(self, search_matches, filterspec, sort, group, 
881             num_re = re.compile('^\d+$')):
882         ''' Return a list of the ids of the active nodes in this class that
883             match the 'filter' spec, sorted by the group spec and then the
884             sort spec
885         '''
886         cn = self.classname
888         # optimise filterspec
889         l = []
890         props = self.getprops()
891         for k, v in filterspec.items():
892             propclass = props[k]
893             if isinstance(propclass, Link):
894                 if type(v) is not type([]):
895                     v = [v]
896                 # replace key values with node ids
897                 u = []
898                 link_class =  self.db.classes[propclass.classname]
899                 for entry in v:
900                     if entry == '-1': entry = None
901                     elif not num_re.match(entry):
902                         try:
903                             entry = link_class.lookup(entry)
904                         except (TypeError,KeyError):
905                             raise ValueError, 'property "%s": %s not a %s'%(
906                                 k, entry, self.properties[k].classname)
907                     u.append(entry)
909                 l.append((0, k, u))
910             elif isinstance(propclass, Multilink):
911                 if type(v) is not type([]):
912                     v = [v]
913                 # replace key values with node ids
914                 u = []
915                 link_class =  self.db.classes[propclass.classname]
916                 for entry in v:
917                     if not num_re.match(entry):
918                         try:
919                             entry = link_class.lookup(entry)
920                         except (TypeError,KeyError):
921                             raise ValueError, 'new property "%s": %s not a %s'%(
922                                 k, entry, self.properties[k].classname)
923                     u.append(entry)
924                 l.append((1, k, u))
925             elif isinstance(propclass, String):
926                 # simple glob searching
927                 v = re.sub(r'([\|\{\}\\\.\+\[\]\(\)])', r'\\\1', v)
928                 v = v.replace('?', '.')
929                 v = v.replace('*', '.*?')
930                 l.append((2, k, re.compile(v, re.I)))
931             else:
932                 l.append((6, k, v))
933         filterspec = l
935         # now, find all the nodes that are active and pass filtering
936         l = []
937         cldb = self.db.getclassdb(cn)
938         for nodeid in self.db.getnodeids(cn, cldb):
939             node = self.db.getnode(cn, nodeid, cldb)
940             if node.has_key(self.db.RETIRED_FLAG):
941                 continue
942             # apply filter
943             for t, k, v in filterspec:
944                 # this node doesn't have this property, so reject it
945                 if not node.has_key(k): break
947                 if t == 0 and node[k] not in v:
948                     # link - if this node'd property doesn't appear in the
949                     # filterspec's nodeid list, skip it
950                     break
951                 elif t == 1:
952                     # multilink - if any of the nodeids required by the
953                     # filterspec aren't in this node's property, then skip
954                     # it
955                     for value in v:
956                         if value not in node[k]:
957                             break
958                     else:
959                         continue
960                     break
961                 elif t == 2 and (node[k] is None or not v.search(node[k])):
962                     # RE search
963                     break
964                 elif t == 6 and node[k] != v:
965                     # straight value comparison for the other types
966                     break
967             else:
968                 l.append((nodeid, node))
969         l.sort()
971         # filter based on full text search
972         if search_matches is not None:
973             k = []
974             l_debug = []
975             for v in l:
976                 l_debug.append(v[0])
977                 if search_matches.has_key(v[0]):
978                     k.append(v)
979             l = k
981         # optimise sort
982         m = []
983         for entry in sort:
984             if entry[0] != '-':
985                 m.append(('+', entry))
986             else:
987                 m.append((entry[0], entry[1:]))
988         sort = m
990         # optimise group
991         m = []
992         for entry in group:
993             if entry[0] != '-':
994                 m.append(('+', entry))
995             else:
996                 m.append((entry[0], entry[1:]))
997         group = m
998         # now, sort the result
999         def sortfun(a, b, sort=sort, group=group, properties=self.getprops(),
1000                 db = self.db, cl=self):
1001             a_id, an = a
1002             b_id, bn = b
1003             # sort by group and then sort
1004             for list in group, sort:
1005                 for dir, prop in list:
1006                     # sorting is class-specific
1007                     propclass = properties[prop]
1009                     # handle the properties that might be "faked"
1010                     # also, handle possible missing properties
1011                     try:
1012                         if not an.has_key(prop):
1013                             an[prop] = cl.get(a_id, prop)
1014                         av = an[prop]
1015                     except KeyError:
1016                         # the node doesn't have a value for this property
1017                         if isinstance(propclass, Multilink): av = []
1018                         else: av = ''
1019                     try:
1020                         if not bn.has_key(prop):
1021                             bn[prop] = cl.get(b_id, prop)
1022                         bv = bn[prop]
1023                     except KeyError:
1024                         # the node doesn't have a value for this property
1025                         if isinstance(propclass, Multilink): bv = []
1026                         else: bv = ''
1028                     # String and Date values are sorted in the natural way
1029                     if isinstance(propclass, String):
1030                         # clean up the strings
1031                         if av and av[0] in string.uppercase:
1032                             av = an[prop] = av.lower()
1033                         if bv and bv[0] in string.uppercase:
1034                             bv = bn[prop] = bv.lower()
1035                     if (isinstance(propclass, String) or
1036                             isinstance(propclass, Date)):
1037                         # it might be a string that's really an integer
1038                         try:
1039                             av = int(av)
1040                             bv = int(bv)
1041                         except:
1042                             pass
1043                         if dir == '+':
1044                             r = cmp(av, bv)
1045                             if r != 0: return r
1046                         elif dir == '-':
1047                             r = cmp(bv, av)
1048                             if r != 0: return r
1050                     # Link properties are sorted according to the value of
1051                     # the "order" property on the linked nodes if it is
1052                     # present; or otherwise on the key string of the linked
1053                     # nodes; or finally on  the node ids.
1054                     elif isinstance(propclass, Link):
1055                         link = db.classes[propclass.classname]
1056                         if av is None and bv is not None: return -1
1057                         if av is not None and bv is None: return 1
1058                         if av is None and bv is None: continue
1059                         if link.getprops().has_key('order'):
1060                             if dir == '+':
1061                                 r = cmp(link.get(av, 'order'),
1062                                     link.get(bv, 'order'))
1063                                 if r != 0: return r
1064                             elif dir == '-':
1065                                 r = cmp(link.get(bv, 'order'),
1066                                     link.get(av, 'order'))
1067                                 if r != 0: return r
1068                         elif link.getkey():
1069                             key = link.getkey()
1070                             if dir == '+':
1071                                 r = cmp(link.get(av, key), link.get(bv, key))
1072                                 if r != 0: return r
1073                             elif dir == '-':
1074                                 r = cmp(link.get(bv, key), link.get(av, key))
1075                                 if r != 0: return r
1076                         else:
1077                             if dir == '+':
1078                                 r = cmp(av, bv)
1079                                 if r != 0: return r
1080                             elif dir == '-':
1081                                 r = cmp(bv, av)
1082                                 if r != 0: return r
1084                     # Multilink properties are sorted according to how many
1085                     # links are present.
1086                     elif isinstance(propclass, Multilink):
1087                         if dir == '+':
1088                             r = cmp(len(av), len(bv))
1089                             if r != 0: return r
1090                         elif dir == '-':
1091                             r = cmp(len(bv), len(av))
1092                             if r != 0: return r
1093                 # end for dir, prop in list:
1094             # end for list in sort, group:
1095             # if all else fails, compare the ids
1096             return cmp(a[0], b[0])
1098         l.sort(sortfun)
1099         return [i[0] for i in l]
1101     def count(self):
1102         """Get the number of nodes in this class.
1104         If the returned integer is 'numnodes', the ids of all the nodes
1105         in this class run from 1 to numnodes, and numnodes+1 will be the
1106         id of the next node to be created in this class.
1107         """
1108         return self.db.countnodes(self.classname)
1110     # Manipulating properties:
1112     def getprops(self, protected=1):
1113         """Return a dictionary mapping property names to property objects.
1114            If the "protected" flag is true, we include protected properties -
1115            those which may not be modified."""
1116         d = self.properties.copy()
1117         if protected:
1118             d['id'] = String()
1119         return d
1121     def addprop(self, **properties):
1122         """Add properties to this class.
1124         The keyword arguments in 'properties' must map names to property
1125         objects, or a TypeError is raised.  None of the keys in 'properties'
1126         may collide with the names of existing properties, or a ValueError
1127         is raised before any properties have been added.
1128         """
1129         for key in properties.keys():
1130             if self.properties.has_key(key):
1131                 raise ValueError, key
1132         self.properties.update(properties)
1134     def index(self, nodeid):
1135         '''Add (or refresh) the node to search indexes
1136         '''
1137         # find all the String properties that have indexme
1138         for prop, propclass in self.getprops().items():
1139             if isinstance(propclass, String) and propclass.indexme:
1140                 # and index them under (classname, nodeid, property)
1141                 self.db.indexer.add_text((self.classname, nodeid, prop),
1142                     str(self.get(nodeid, prop)))
1144 # XXX not in spec
1145 class Node:
1146     ''' A convenience wrapper for the given node
1147     '''
1148     def __init__(self, cl, nodeid, cache=1):
1149         self.__dict__['cl'] = cl
1150         self.__dict__['nodeid'] = nodeid
1151         self.__dict__['cache'] = cache
1152     def keys(self, protected=1):
1153         return self.cl.getprops(protected=protected).keys()
1154     def values(self, protected=1):
1155         l = []
1156         for name in self.cl.getprops(protected=protected).keys():
1157             l.append(self.cl.get(self.nodeid, name, cache=self.cache))
1158         return l
1159     def items(self, protected=1):
1160         l = []
1161         for name in self.cl.getprops(protected=protected).keys():
1162             l.append((name, self.cl.get(self.nodeid, name, cache=self.cache)))
1163         return l
1164     def has_key(self, name):
1165         return self.cl.getprops().has_key(name)
1166     def __getattr__(self, name):
1167         if self.__dict__.has_key(name):
1168             return self.__dict__[name]
1169         try:
1170             return self.cl.get(self.nodeid, name, cache=self.cache)
1171         except KeyError, value:
1172             # we trap this but re-raise it as AttributeError - all other
1173             # exceptions should pass through untrapped
1174             pass
1175         # nope, no such attribute
1176         raise AttributeError, str(value)
1177     def __getitem__(self, name):
1178         return self.cl.get(self.nodeid, name, cache=self.cache)
1179     def __setattr__(self, name, value):
1180         try:
1181             return self.cl.set(self.nodeid, **{name: value})
1182         except KeyError, value:
1183             raise AttributeError, str(value)
1184     def __setitem__(self, name, value):
1185         self.cl.set(self.nodeid, **{name: value})
1186     def history(self):
1187         return self.cl.history(self.nodeid)
1188     def retire(self):
1189         return self.cl.retire(self.nodeid)
1192 def Choice(name, db, *options):
1193     '''Quick helper to create a simple class with choices
1194     '''
1195     cl = Class(db, name, name=String(), order=String())
1196     for i in range(len(options)):
1197         cl.create(name=options[i], order=i)
1198     return hyperdb.Link(name)
1201 # $Log: not supported by cvs2svn $
1202 # Revision 1.71  2002/07/09 03:02:52  richard
1203 # More indexer work:
1204 # - all String properties may now be indexed too. Currently there's a bit of
1205 #   "issue" specific code in the actual searching which needs to be
1206 #   addressed. In a nutshell:
1207 #   + pass 'indexme="yes"' as a String() property initialisation arg, eg:
1208 #         file = FileClass(db, "file", name=String(), type=String(),
1209 #             comment=String(indexme="yes"))
1210 #   + the comment will then be indexed and be searchable, with the results
1211 #     related back to the issue that the file is linked to
1212 # - as a result of this work, the FileClass has a default MIME type that may
1213 #   be overridden in a subclass, or by the use of a "type" property as is
1214 #   done in the default templates.
1215 # - the regeneration of the indexes (if necessary) is done once the schema is
1216 #   set up in the dbinit.
1218 # Revision 1.70  2002/06/27 12:06:20  gmcm
1219 # Improve an error message.
1221 # Revision 1.69  2002/06/17 23:15:29  richard
1222 # Can debug to stdout now
1224 # Revision 1.68  2002/06/11 06:52:03  richard
1225 #  . #564271 ] find() and new properties
1227 # Revision 1.67  2002/06/11 05:02:37  richard
1228 #  . #565979 ] code error in hyperdb.Class.find
1230 # Revision 1.66  2002/05/25 07:16:24  rochecompaan
1231 # Merged search_indexing-branch with HEAD
1233 # Revision 1.65  2002/05/22 04:12:05  richard
1234 #  . applied patch #558876 ] cgi client customization
1235 #    ... with significant additions and modifications ;)
1236 #    - extended handling of ML assignedto to all places it's handled
1237 #    - added more NotFound info
1239 # Revision 1.64  2002/05/15 06:21:21  richard
1240 #  . node caching now works, and gives a small boost in performance
1242 # As a part of this, I cleaned up the DEBUG output and implemented TRACE
1243 # output (HYPERDBTRACE='file to trace to') with checkpoints at the start of
1244 # CGI requests. Run roundup with python -O to skip all the DEBUG/TRACE stuff
1245 # (using if __debug__ which is compiled out with -O)
1247 # Revision 1.63  2002/04/15 23:25:15  richard
1248 # . node ids are now generated from a lockable store - no more race conditions
1250 # We're using the portalocker code by Jonathan Feinberg that was contributed
1251 # to the ASPN Python cookbook. This gives us locking across Unix and Windows.
1253 # Revision 1.62  2002/04/03 07:05:50  richard
1254 # d'oh! killed retirement of nodes :(
1255 # all better now...
1257 # Revision 1.61  2002/04/03 06:11:51  richard
1258 # Fix for old databases that contain properties that don't exist any more.
1260 # Revision 1.60  2002/04/03 05:54:31  richard
1261 # Fixed serialisation problem by moving the serialisation step out of the
1262 # hyperdb.Class (get, set) into the hyperdb.Database.
1264 # Also fixed htmltemplate after the showid changes I made yesterday.
1266 # Unit tests for all of the above written.
1268 # Revision 1.59.2.2  2002/04/20 13:23:33  rochecompaan
1269 # We now have a separate search page for nodes.  Search links for
1270 # different classes can be customized in instance_config similar to
1271 # index links.
1273 # Revision 1.59.2.1  2002/04/19 19:54:42  rochecompaan
1274 # cgi_client.py
1275 #     removed search link for the time being
1276 #     moved rendering of matches to htmltemplate
1277 # hyperdb.py
1278 #     filtering of nodes on full text search incorporated in filter method
1279 # roundupdb.py
1280 #     added paramater to call of filter method
1281 # roundup_indexer.py
1282 #     added search method to RoundupIndexer class
1284 # Revision 1.59  2002/03/12 22:52:26  richard
1285 # more pychecker warnings removed
1287 # Revision 1.58  2002/02/27 03:23:16  richard
1288 # Ran it through pychecker, made fixes
1290 # Revision 1.57  2002/02/20 05:23:24  richard
1291 # Didn't accomodate new values for new properties
1293 # Revision 1.56  2002/02/20 05:05:28  richard
1294 #  . Added simple editing for classes that don't define a templated interface.
1295 #    - access using the admin "class list" interface
1296 #    - limited to admin-only
1297 #    - requires the csv module from object-craft (url given if it's missing)
1299 # Revision 1.55  2002/02/15 07:27:12  richard
1300 # Oops, precedences around the way w0rng.
1302 # Revision 1.54  2002/02/15 07:08:44  richard
1303 #  . Alternate email addresses are now available for users. See the MIGRATION
1304 #    file for info on how to activate the feature.
1306 # Revision 1.53  2002/01/22 07:21:13  richard
1307 # . fixed back_bsddb so it passed the journal tests
1309 # ... it didn't seem happy using the back_anydbm _open method, which is odd.
1310 # Yet another occurrance of whichdb not being able to recognise older bsddb
1311 # databases. Yadda yadda. Made the HYPERDBDEBUG stuff more sane in the
1312 # process.
1314 # Revision 1.52  2002/01/21 16:33:19  rochecompaan
1315 # You can now use the roundup-admin tool to pack the database
1317 # Revision 1.51  2002/01/21 03:01:29  richard
1318 # brief docco on the do_journal argument
1320 # Revision 1.50  2002/01/19 13:16:04  rochecompaan
1321 # Journal entries for link and multilink properties can now be switched on
1322 # or off.
1324 # Revision 1.49  2002/01/16 07:02:57  richard
1325 #  . lots of date/interval related changes:
1326 #    - more relaxed date format for input
1328 # Revision 1.48  2002/01/14 06:32:34  richard
1329 #  . #502951 ] adding new properties to old database
1331 # Revision 1.47  2002/01/14 02:20:15  richard
1332 #  . changed all config accesses so they access either the instance or the
1333 #    config attriubute on the db. This means that all config is obtained from
1334 #    instance_config instead of the mish-mash of classes. This will make
1335 #    switching to a ConfigParser setup easier too, I hope.
1337 # At a minimum, this makes migration a _little_ easier (a lot easier in the
1338 # 0.5.0 switch, I hope!)
1340 # Revision 1.46  2002/01/07 10:42:23  richard
1341 # oops
1343 # Revision 1.45  2002/01/02 04:18:17  richard
1344 # hyperdb docstrings
1346 # Revision 1.44  2002/01/02 02:31:38  richard
1347 # Sorry for the huge checkin message - I was only intending to implement #496356
1348 # but I found a number of places where things had been broken by transactions:
1349 #  . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename
1350 #    for _all_ roundup-generated smtp messages to be sent to.
1351 #  . the transaction cache had broken the roundupdb.Class set() reactors
1352 #  . newly-created author users in the mailgw weren't being committed to the db
1354 # Stuff that made it into CHANGES.txt (ie. the stuff I was actually working
1355 # on when I found that stuff :):
1356 #  . #496356 ] Use threading in messages
1357 #  . detectors were being registered multiple times
1358 #  . added tests for mailgw
1359 #  . much better attaching of erroneous messages in the mail gateway
1361 # Revision 1.43  2001/12/20 06:13:24  rochecompaan
1362 # Bugs fixed:
1363 #   . Exception handling in hyperdb for strings-that-look-like numbers got
1364 #     lost somewhere
1365 #   . Internet Explorer submits full path for filename - we now strip away
1366 #     the path
1367 # Features added:
1368 #   . Link and multilink properties are now displayed sorted in the cgi
1369 #     interface
1371 # Revision 1.42  2001/12/16 10:53:37  richard
1372 # take a copy of the node dict so that the subsequent set
1373 # operation doesn't modify the oldvalues structure
1375 # Revision 1.41  2001/12/15 23:47:47  richard
1376 # Cleaned up some bare except statements
1378 # Revision 1.40  2001/12/14 23:42:57  richard
1379 # yuck, a gdbm instance tests false :(
1380 # I've left the debugging code in - it should be removed one day if we're ever
1381 # _really_ anal about performace :)
1383 # Revision 1.39  2001/12/02 05:06:16  richard
1384 # . We now use weakrefs in the Classes to keep the database reference, so
1385 #   the close() method on the database is no longer needed.
1386 #   I bumped the minimum python requirement up to 2.1 accordingly.
1387 # . #487480 ] roundup-server
1388 # . #487476 ] INSTALL.txt
1390 # I also cleaned up the change message / post-edit stuff in the cgi client.
1391 # There's now a clearly marked "TODO: append the change note" where I believe
1392 # the change note should be added there. The "changes" list will obviously
1393 # have to be modified to be a dict of the changes, or somesuch.
1395 # More testing needed.
1397 # Revision 1.38  2001/12/01 07:17:50  richard
1398 # . We now have basic transaction support! Information is only written to
1399 #   the database when the commit() method is called. Only the anydbm
1400 #   backend is modified in this way - neither of the bsddb backends have been.
1401 #   The mail, admin and cgi interfaces all use commit (except the admin tool
1402 #   doesn't have a commit command, so interactive users can't commit...)
1403 # . Fixed login/registration forwarding the user to the right page (or not,
1404 #   on a failure)
1406 # Revision 1.37  2001/11/28 21:55:35  richard
1407 #  . login_action and newuser_action return values were being ignored
1408 #  . Woohoo! Found that bloody re-login bug that was killing the mail
1409 #    gateway.
1410 #  (also a minor cleanup in hyperdb)
1412 # Revision 1.36  2001/11/27 03:16:09  richard
1413 # Another place that wasn't handling missing properties.
1415 # Revision 1.35  2001/11/22 15:46:42  jhermann
1416 # Added module docstrings to all modules.
1418 # Revision 1.34  2001/11/21 04:04:43  richard
1419 # *sigh* more missing value handling
1421 # Revision 1.33  2001/11/21 03:40:54  richard
1422 # more new property handling
1424 # Revision 1.32  2001/11/21 03:11:28  richard
1425 # Better handling of new properties.
1427 # Revision 1.31  2001/11/12 22:01:06  richard
1428 # Fixed issues with nosy reaction and author copies.
1430 # Revision 1.30  2001/11/09 10:11:08  richard
1431 #  . roundup-admin now handles all hyperdb exceptions
1433 # Revision 1.29  2001/10/27 00:17:41  richard
1434 # Made Class.stringFind() do caseless matching.
1436 # Revision 1.28  2001/10/21 04:44:50  richard
1437 # bug #473124: UI inconsistency with Link fields.
1438 #    This also prompted me to fix a fairly long-standing usability issue -
1439 #    that of being able to turn off certain filters.
1441 # Revision 1.27  2001/10/20 23:44:27  richard
1442 # Hyperdatabase sorts strings-that-look-like-numbers as numbers now.
1444 # Revision 1.26  2001/10/16 03:48:01  richard
1445 # admin tool now complains if a "find" is attempted with a non-link property.
1447 # Revision 1.25  2001/10/11 00:17:51  richard
1448 # Reverted a change in hyperdb so the default value for missing property
1449 # values in a create() is None and not '' (the empty string.) This obviously
1450 # breaks CSV import/export - the string 'None' will be created in an
1451 # export/import operation.
1453 # Revision 1.24  2001/10/10 03:54:57  richard
1454 # Added database importing and exporting through CSV files.
1455 # Uses the csv module from object-craft for exporting if it's available.
1456 # Requires the csv module for importing.
1458 # Revision 1.23  2001/10/09 23:58:10  richard
1459 # Moved the data stringification up into the hyperdb.Class class' get, set
1460 # and create methods. This means that the data is also stringified for the
1461 # journal call, and removes duplication of code from the backends. The
1462 # backend code now only sees strings.
1464 # Revision 1.22  2001/10/09 07:25:59  richard
1465 # Added the Password property type. See "pydoc roundup.password" for
1466 # implementation details. Have updated some of the documentation too.
1468 # Revision 1.21  2001/10/05 02:23:24  richard
1469 #  . roundup-admin create now prompts for property info if none is supplied
1470 #    on the command-line.
1471 #  . hyperdb Class getprops() method may now return only the mutable
1472 #    properties.
1473 #  . Login now uses cookies, which makes it a whole lot more flexible. We can
1474 #    now support anonymous user access (read-only, unless there's an
1475 #    "anonymous" user, in which case write access is permitted). Login
1476 #    handling has been moved into cgi_client.Client.main()
1477 #  . The "extended" schema is now the default in roundup init.
1478 #  . The schemas have had their page headings modified to cope with the new
1479 #    login handling. Existing installations should copy the interfaces.py
1480 #    file from the roundup lib directory to their instance home.
1481 #  . Incorrectly had a Bizar Software copyright on the cgitb.py module from
1482 #    Ping - has been removed.
1483 #  . Fixed a whole bunch of places in the CGI interface where we should have
1484 #    been returning Not Found instead of throwing an exception.
1485 #  . Fixed a deviation from the spec: trying to modify the 'id' property of
1486 #    an item now throws an exception.
1488 # Revision 1.20  2001/10/04 02:12:42  richard
1489 # Added nicer command-line item adding: passing no arguments will enter an
1490 # interactive more which asks for each property in turn. While I was at it, I
1491 # fixed an implementation problem WRT the spec - I wasn't raising a
1492 # ValueError if the key property was missing from a create(). Also added a
1493 # protected=boolean argument to getprops() so we can list only the mutable
1494 # properties (defaults to yes, which lists the immutables).
1496 # Revision 1.19  2001/08/29 04:47:18  richard
1497 # Fixed CGI client change messages so they actually include the properties
1498 # changed (again).
1500 # Revision 1.18  2001/08/16 07:34:59  richard
1501 # better CGI text searching - but hidden filter fields are disappearing...
1503 # Revision 1.17  2001/08/16 06:59:58  richard
1504 # all searches use re now - and they're all case insensitive
1506 # Revision 1.16  2001/08/15 23:43:18  richard
1507 # Fixed some isFooTypes that I missed.
1508 # Refactored some code in the CGI code.
1510 # Revision 1.15  2001/08/12 06:32:36  richard
1511 # using isinstance(blah, Foo) now instead of isFooType
1513 # Revision 1.14  2001/08/07 00:24:42  richard
1514 # stupid typo
1516 # Revision 1.13  2001/08/07 00:15:51  richard
1517 # Added the copyright/license notice to (nearly) all files at request of
1518 # Bizar Software.
1520 # Revision 1.12  2001/08/02 06:38:17  richard
1521 # Roundupdb now appends "mailing list" information to its messages which
1522 # include the e-mail address and web interface address. Templates may
1523 # override this in their db classes to include specific information (support
1524 # instructions, etc).
1526 # Revision 1.11  2001/08/01 04:24:21  richard
1527 # mailgw was assuming certain properties existed on the issues being created.
1529 # Revision 1.10  2001/07/30 02:38:31  richard
1530 # get() now has a default arg - for migration only.
1532 # Revision 1.9  2001/07/29 09:28:23  richard
1533 # Fixed sorting by clicking on column headings.
1535 # Revision 1.8  2001/07/29 08:27:40  richard
1536 # Fixed handling of passed-in values in form elements (ie. during a
1537 # drill-down)
1539 # Revision 1.7  2001/07/29 07:01:39  richard
1540 # Added vim command to all source so that we don't get no steenkin' tabs :)
1542 # Revision 1.6  2001/07/29 05:36:14  richard
1543 # Cleanup of the link label generation.
1545 # Revision 1.5  2001/07/29 04:05:37  richard
1546 # Added the fabricated property "id".
1548 # Revision 1.4  2001/07/27 06:25:35  richard
1549 # Fixed some of the exceptions so they're the right type.
1550 # Removed the str()-ification of node ids so we don't mask oopsy errors any
1551 # more.
1553 # Revision 1.3  2001/07/27 05:17:14  richard
1554 # just some comments
1556 # Revision 1.2  2001/07/22 12:09:32  richard
1557 # Final commit of Grande Splite
1559 # Revision 1.1  2001/07/22 11:58:35  richard
1560 # More Grande Splite
1563 # vim: set filetype=python ts=4 sw=4 et si