[Zope-dev] ZPatterns: SAVING doesn't tolerate missing attributes
Steve Alexander
steve@cat-box.net
Sat, 06 Jan 2001 17:48:26 +0000
Steve Spicklemire wrote:
> Hi Steve,
>
> Could you let some other value represent no car? (e.g., _.None?).
>
> untested...
>
> WITH CompanyCars.getCar(self.car_id) or NOT_FOUND COMPUTE
> car=RESULT,
> car_registration=registration
> OTHERWISE LET
> car=_.None
> car_registration="no car"
>
> WHEN OBJECT CHANGED CALL
> HAS_CHANGED('car_id') and
> (self.car_id and CompanyCars.getItem(self.car_id).decommission(),
> ORIGINAL['car_id'] and (OLD['car'] and OLD['car'].commission()))
> SAVING car
>
> Would that work?
Sure, that would work.
The workaround I've chosen is to use
CompanyCars.getItem(ORIGINAL['car_id']).commission()
in place of
OLD['car'].commission()
Oh, and I jsut noticed, I had commission and decommission the wrong way
around in the example :-)
I'd still prefer SAVING to tolerate not-found attributes, though.
--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net