Changeset 377
- Timestamp:
- 01/06/07 20:31:55
- Files:
-
- trunk/units.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/units.py
r376 r377 666 666 indices = classmethod(indices) 667 667 668 def adjust(self, **values): 669 """Set UnitProperties by key, value kwargs.""" 668 def update(self, **values): 669 """Modify this Unit's property values (via keyword arguments). 670 671 The keyword arguments you supply will be checked against this 672 Unit's known properties; only known properties will be updated. 673 This keeps applications which accept arbitrary parameters safer. 674 """ 670 675 for key, val in values.iteritems(): 671 setattr(self, key, val) 676 if key in self.properties: 677 setattr(self, key, val) 672 678 673 679 … … 715 721 ua = cls._associations[unit.__class__.__name__] 716 722 except KeyError: 717 msg = " '%s' is not associated with '%s'" % (cls, unit.__class__)723 msg = "%r is not associated with %r" % (cls, unit.__class__) 718 724 raise errors.AssociationError(msg) 719 725 … … 722 728 if nearval is None: 723 729 if farval is None: 724 raise errors.AssociationError("At least one Unit key must be set.") 730 msg = ("%r and %r could not be related, since neither " 731 "has an ID yet. Memorize the parent Unit before " 732 "calling unitA.add(unitB)." % (self, unit)) 733 raise errors.AssociationError(msg) 725 734 else: 726 735 setattr(self, ua.nearKey, farval)
