Re: Python 2.3 and booleans

Sebastien Bigaret <[email protected]> 16 Apr 2004 14:25:51 +0200
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
        Hi Yannick,

  Not sure I fully understand what effect you want here, just in case
this can help: you can transform any attribute's value stored as an int
in the db into py2.3 boolean automaticall=y by using a KeyValueCoding
private setter, like that:


    def _setMyAttribute(self, value):
        self.value=bool(value)

(this is in fact the very same technique exposed here:
 http://modeling.sourceforge.net/UserGuide/attribute-custom-type.html)


    If it's not what you need, could you also give a little example?

(admittedly I've read your msg quickly and answering the same way...)

  and I'll have a look at Arch when I find time ;)  Any idea on whether
  it wirks on sf?

-- Sébastien.



Yannick Gingras <[email protected]> writes:

> Hi, 
>   we just upgraded to Python 2.3.  As you probably know, Python 2.3
> now has a boolean type so repr(a == b) is no longer 0 or 1 but True or
> False.
> 
> We use some int(1) in our database to represent booleans but now all
> our queries involving those fields are broken.
> 
> This is absolutely not a Modeling problem but I think that I can use
> Modeling to reconvert those values just before the query.  That would
> solve quite a lot of work here.
> 
> Any of you guys had the same problem when switching to Python 2.3 ?
> 
> Should I tweak Modeling to make the conversion automatically ?  Can it
> break anything somewhere else ?
> 
> And absolutely unrelated to this problem, I've been using GNU Arch
> lately instead of CVS.  It features GPG signed commits and ease
> maintaining branches in synch.  If Modeling used Arch, we could make
> the changes to automate booleans conversions in our branch and still
> stay up to date with the main branch in case someone else would like
> to have this particular feature and Sebastian find our code too ugly
> to be merged yet...
> 
>  ; )
> 
> Enough propaganda, thanks for your time guys !
> 



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click