Mercurial > p > roundup > code
comparison roundup/hyperdb.py @ 825:0779ea9f1f18
More indexer work:
- all String properties may now be indexed too. Currently there's a bit of
"issue" specific code in the actual searching which needs to be
addressed. In a nutshell:
+ pass 'indexme="yes"' as a String() property initialisation arg, eg:
file = FileClass(db, "file", name=String(), type=String(),
comment=String(indexme="yes"))
+ the comment will then be indexed and be searchable, with the results
related back to the issue that the file is linked to
- as a result of this work, the FileClass has a default MIME type that may
be overridden in a subclass, or by the use of a "type" property as is
done in the default templates.
- the regeneration of the indexes (if necessary) is done once the schema is
set up in the dbinit.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 09 Jul 2002 03:02:53 +0000 |
| parents | 6937eb92061f |
| children | 568eed5fb4fd |
comparison
equal
deleted
inserted
replaced
| 824:34eacaa7e313 | 825:0779ea9f1f18 |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 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" | 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, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: hyperdb.py,v 1.70 2002-06-27 12:06:20 gmcm Exp $ | 18 # $Id: hyperdb.py,v 1.71 2002-07-09 03:02:52 richard Exp $ |
| 19 | 19 |
| 20 __doc__ = """ | 20 __doc__ = """ |
| 21 Hyperdatabase implementation, especially field types. | 21 Hyperdatabase implementation, especially field types. |
| 22 """ | 22 """ |
| 23 | 23 |
| 54 # | 54 # |
| 55 # Types | 55 # Types |
| 56 # | 56 # |
| 57 class String: | 57 class String: |
| 58 """An object designating a String property.""" | 58 """An object designating a String property.""" |
| 59 def __init__(self, indexme='no'): | |
| 60 self.indexme = indexme == 'yes' | |
| 59 def __repr__(self): | 61 def __repr__(self): |
| 60 ' more useful for dumps ' | 62 ' more useful for dumps ' |
| 61 return '<%s>'%self.__class__ | 63 return '<%s>'%self.__class__ |
| 62 | 64 |
| 63 class Password: | 65 class Password: |
| 153 The 'journaltag' is a token that will be attached to the journal | 155 The 'journaltag' is a token that will be attached to the journal |
| 154 entries for any edits done on the database. If 'journaltag' is | 156 entries for any edits done on the database. If 'journaltag' is |
| 155 None, the database is opened in read-only mode: the Class.create(), | 157 None, the database is opened in read-only mode: the Class.create(), |
| 156 Class.set(), and Class.retire() methods are disabled. | 158 Class.set(), and Class.retire() methods are disabled. |
| 157 """ | 159 """ |
| 160 raise NotImplementedError | |
| 161 | |
| 162 def post_init(self): | |
| 163 """Called once the schema initialisation has finished.""" | |
| 158 raise NotImplementedError | 164 raise NotImplementedError |
| 159 | 165 |
| 160 def __getattr__(self, classname): | 166 def __getattr__(self, classname): |
| 161 """A convenient way of calling self.getclass(classname).""" | 167 """A convenient way of calling self.getclass(classname).""" |
| 162 raise NotImplementedError | 168 raise NotImplementedError |
| 1108 """ | 1114 """ |
| 1109 for key in properties.keys(): | 1115 for key in properties.keys(): |
| 1110 if self.properties.has_key(key): | 1116 if self.properties.has_key(key): |
| 1111 raise ValueError, key | 1117 raise ValueError, key |
| 1112 self.properties.update(properties) | 1118 self.properties.update(properties) |
| 1119 | |
| 1120 def index(self, nodeid): | |
| 1121 '''Add (or refresh) the node to search indexes | |
| 1122 ''' | |
| 1123 # find all the String properties that have indexme | |
| 1124 for prop, propclass in self.getprops().items(): | |
| 1125 if isinstance(propclass, String) and propclass.indexme: | |
| 1126 # and index them under (classname, nodeid, property) | |
| 1127 self.db.indexer.add_text((self.classname, nodeid, prop), | |
| 1128 str(self.get(nodeid, prop))) | |
| 1113 | 1129 |
| 1114 # XXX not in spec | 1130 # XXX not in spec |
| 1115 class Node: | 1131 class Node: |
| 1116 ''' A convenience wrapper for the given node | 1132 ''' A convenience wrapper for the given node |
| 1117 ''' | 1133 ''' |
| 1167 cl.create(name=options[i], order=i) | 1183 cl.create(name=options[i], order=i) |
| 1168 return hyperdb.Link(name) | 1184 return hyperdb.Link(name) |
| 1169 | 1185 |
| 1170 # | 1186 # |
| 1171 # $Log: not supported by cvs2svn $ | 1187 # $Log: not supported by cvs2svn $ |
| 1188 # Revision 1.70 2002/06/27 12:06:20 gmcm | |
| 1189 # Improve an error message. | |
| 1190 # | |
| 1172 # Revision 1.69 2002/06/17 23:15:29 richard | 1191 # Revision 1.69 2002/06/17 23:15:29 richard |
| 1173 # Can debug to stdout now | 1192 # Can debug to stdout now |
| 1174 # | 1193 # |
| 1175 # Revision 1.68 2002/06/11 06:52:03 richard | 1194 # Revision 1.68 2002/06/11 06:52:03 richard |
| 1176 # . #564271 ] find() and new properties | 1195 # . #564271 ] find() and new properties |
