Re: [Modeling-users] Handling custom types for attributes
Status: Abandoned
Brought to you by:
sbigaret
From: Mario R. <ma...@ru...> - 2003-12-21 19:27:10
|
>> I would like to use custom FixedPoint values for an attribute of an >> object. >> So, I do as the example in Chapter 9 of the userguide suggests... so >> I define >> the "private" methods obj._setX(val) and obj._getX(). However, when >> the >> client code calls the corresponding public setX and getX methods, the >> private ones are never called! Any ideas what I may be missing out on? >> I am using 0.9-pre-16 of modeling plus bug862182.patch >> (no other patches I think). > > Well, I think there should be something obscure in the doc. if it made > you think that public methods call the corresponding private ones. It > is > definitely not the case (at least by default, nothing prevents you from > doing this). > > Private accessors (as searched by KeyValueCoding.storedValueForKey) > are the only one used by the framework. That's why they can be used, > in particular, to define transformation from sql types to custom > types. > > Without more info. I cannot really tell why this bothers you so much :) Hmmn, I have mis-assumed ;(( It bothers me because it does not do what I expect! If I add the following "balance" methods to a MyCustomObject class: def _setBalance(self, value): if value is None: self._balance=None else: self._balance = FixedPoint(value, 6) def _getBalance(self): if not self._balance: return None else: return str(self._balance) Then, in an interactive session: >>> a = MyCustomObject() >>> a.getBalance() '' >>> a.setBalance(FixedPoint('123.456')) >>> a.getBalance() FixedPoint('123.46', 2) >>> Thus, on first getBalance() I should get None. And on second getBalance() I should get a FixedPoint of pecision 6 not 2. I am missing something! It is late weekend, and I stop! Cheers, mario |