|
1 | | -# $Id: rdbms_common.py,v 1.98.2.26 2004-11-09 04:10:28 richard Exp $ |
| 1 | +# $Id: rdbms_common.py,v 1.98.2.27 2004-11-10 22:26:07 richard Exp $ |
2 | 2 | ''' Relational database (SQL) backend common code. |
3 | 3 |
|
4 | 4 | Basics: |
@@ -1420,7 +1420,9 @@ def create_inner(self, **propvalues): |
1420 | 1420 | elif isinstance(prop, String): |
1421 | 1421 | if type(value) != type('') and type(value) != type(u''): |
1422 | 1422 | raise TypeError, 'new property "%s" not a string'%key |
1423 | | - self.db.indexer.add_text((self.classname, newid, key), value) |
| 1423 | + if prop.indexme: |
| 1424 | + self.db.indexer.add_text((self.classname, newid, key), |
| 1425 | + value) |
1424 | 1426 |
|
1425 | 1427 | elif isinstance(prop, Password): |
1426 | 1428 | if not isinstance(value, password.Password): |
@@ -1696,8 +1698,9 @@ def set_inner(self, nodeid, **propvalues): |
1696 | 1698 | elif isinstance(prop, String): |
1697 | 1699 | if value is not None and type(value) != type('') and type(value) != type(u''): |
1698 | 1700 | raise TypeError, 'new property "%s" not a string'%propname |
1699 | | - self.db.indexer.add_text((self.classname, nodeid, propname), |
1700 | | - value) |
| 1701 | + if prop.indexme: |
| 1702 | + self.db.indexer.add_text((self.classname, nodeid, propname), |
| 1703 | + value) |
1701 | 1704 |
|
1702 | 1705 | elif isinstance(prop, Password): |
1703 | 1706 | if not isinstance(value, password.Password): |
@@ -2489,11 +2492,14 @@ def import_list(self, propnames, proplist): |
2489 | 2492 | pwd.unpack(value) |
2490 | 2493 | value = pwd |
2491 | 2494 | d[propname] = value |
2492 | | - if isinstance(prop, String) and prop.indexme: |
| 2495 | + if isinstance(prop, String): |
2493 | 2496 | if type(value) != type('') and type(value) != type(u''): |
2494 | | - raise TypeError, 'new property "%s" not a string'%key |
2495 | | - self.db.indexer.add_text((self.classname, newid, propname), |
2496 | | - value) |
| 2497 | + raise TypeError, \ |
| 2498 | + 'new property "%(propname)s" not a string: %(value)r' \ |
| 2499 | + % locals() |
| 2500 | + if prop.indexme: |
| 2501 | + self.db.indexer.add_text((self.classname, newid, propname), |
| 2502 | + value) |
2497 | 2503 |
|
2498 | 2504 | # get a new id if necessary |
2499 | 2505 | if newid is None: |
|
0 commit comments