1- # $Id: rdbms_common.py,v 1.98.2.11 2004-06-24 07:14:48 richard Exp $
1+ # $Id: rdbms_common.py,v 1.98.2.12 2004-06-28 23:15:39 richard Exp $
22''' Relational database (SQL) backend common code.
33
44Basics:
@@ -2421,7 +2421,10 @@ def import_list(self, propnames, proplist):
24212421 # make the new node's property map
24222422 d = {}
24232423 retire = 0
2424- newid = None
2424+ if not "id" in propnames :
2425+ newid = self .db .newid (self .classname )
2426+ else :
2427+ newid = eval (proplist [propnames .index ("id" )])
24252428 for i in range (len (propnames )):
24262429 # Use eval to reverse the repr() used to output the CSV
24272430 value = eval (proplist [i ])
@@ -2431,7 +2434,6 @@ def import_list(self, propnames, proplist):
24312434
24322435 # "unmarshal" where necessary
24332436 if propname == 'id' :
2434- newid = value
24352437 continue
24362438 elif propname == 'is retired' :
24372439 # is the item retired?
@@ -2455,6 +2457,11 @@ def import_list(self, propnames, proplist):
24552457 pwd .unpack (value )
24562458 value = pwd
24572459 d [propname ] = value
2460+ if isinstance (prop , String ) and prop .indexme :
2461+ if type (value ) != type ('' ) and type (value ) != type (u'' ):
2462+ raise TypeError , 'new property "%s" not a string' % key
2463+ self .db .indexer .add_text ((self .classname , newid , propname ),
2464+ value )
24582465
24592466 # get a new id if necessary
24602467 if newid is None :
@@ -2595,10 +2602,12 @@ def get(self, nodeid, propname, default=_marker, cache=1):
25952602 return Class .get (self , nodeid , propname )
25962603
25972604 def getprops (self , protected = 1 ):
2598- ''' In addition to the actual properties on the node, these methods
2599- provide the "content" property. If the "protected" flag is true,
2600- we include protected properties - those which may not be
2601- modified.
2605+ '''In addition to the actual properties on the node, these methods
2606+ provide the "content" property. If the "protected" flag is true,
2607+ we include protected properties - those which may not be
2608+ modified.
2609+
2610+ Note that the content prop is indexed separately, hence no indexme.
26022611 '''
26032612 d = Class .getprops (self , protected = protected ).copy ()
26042613 d ['content' ] = hyperdb .String ()
@@ -2633,6 +2642,18 @@ def set(self, itemid, **propvalues):
26332642 self .fireReactors ('set' , itemid , oldvalues )
26342643 return propvalues
26352644
2645+ def index (self , nodeid ):
2646+ '''Add (or refresh) the node to search indexes.
2647+
2648+ Pass on the content-type property for the content property.
2649+ '''
2650+ Class .index (nodeid )
2651+ mime_type = self .get (itemid , 'type' )
2652+ if not mime_type :
2653+ mime_type = self .default_mime_type
2654+ self .db .indexer .add_text ((self .classname , nodeid , 'content' ),
2655+ str (self .get (nodeid , 'content' )), mime_type )
2656+
26362657# XXX deviation from spec - was called ItemClass
26372658class IssueClass (Class , roundupdb .IssueClass ):
26382659 # Overridden methods:
0 commit comments