Mercurial > p > roundup > code
comparison roundup/volatiledb.py @ 905:502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
The two templates have been migrated to that setup. Lots of unit
tests. Still some issue in the web form for editing Roles assigned to
users.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 26 Jul 2002 08:27:00 +0000 |
| parents | b0d3d3535998 |
| children |
comparison
equal
deleted
inserted
replaced
| 904:02763530b9e8 | 905:502a5ae11cc5 |
|---|---|
| 270 return l | 270 return l |
| 271 | 271 |
| 272 def index(self, nodeid): | 272 def index(self, nodeid): |
| 273 pass | 273 pass |
| 274 | 274 |
| 275 def stringFind(self, **requirements): | |
| 276 """Locate a particular node by matching a set of its String | |
| 277 properties in a caseless search. | |
| 278 | |
| 279 If the property is not a String property, a TypeError is raised. | |
| 280 | |
| 281 The return is a list of the id of all nodes that match. | |
| 282 """ | |
| 283 for propname in requirements.keys(): | |
| 284 prop = self.properties[propname] | |
| 285 if isinstance(not prop, String): | |
| 286 raise TypeError, "'%s' not a String property"%propname | |
| 287 requirements[propname] = requirements[propname].lower() | |
| 288 l = [] | |
| 289 for nodeid, node in self.store.items(): | |
| 290 for key, value in requirements.items(): | |
| 291 if node[key] and node[key].lower() != value: | |
| 292 break | |
| 293 else: | |
| 294 l.append(nodeid) | |
| 295 return l | |
| 296 | |
| 297 def getkey(self): | |
| 298 """Return the name of the key property for this class or None.""" | |
| 299 return self.key | |
| 300 | |
| 301 def labelprop(self, default_to_id=0): | |
| 302 ''' Return the property name for a label for the given node. | |
| 303 | |
| 304 This method attempts to generate a consistent label for the node. | |
| 305 It tries the following in order: | |
| 306 1. key property | |
| 307 2. "name" property | |
| 308 3. "title" property | |
| 309 4. first property from the sorted property name list | |
| 310 ''' | |
| 311 k = self.getkey() | |
| 312 if k: | |
| 313 return k | |
| 314 props = self.getprops() | |
| 315 if props.has_key('name'): | |
| 316 return 'name' | |
| 317 elif props.has_key('title'): | |
| 318 return 'title' | |
| 319 if default_to_id: | |
| 320 return 'id' | |
| 321 props = props.keys() | |
| 322 props.sort() | |
| 323 return props[0] | |
| 324 |
