Discussion:
[Modeling-users] Python 2.3 and booleans
Yannick Gingras
2004-04-15 21:59:05 UTC
Permalink
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 !

- --
Yannick Gingras "please call it ``GNU/Linux''"
Coder for OBB : Officious Billowing Bailey -- Richard M. Stallman
http://OpenBeatBox.org
Sebastien Bigaret
2004-04-16 10:26:10 UTC
Permalink
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.
Post by Yannick Gingras
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 !
Yannick Gingras
2004-04-16 14:44:08 UTC
Permalink
        self.value=bool(value)
 http://modeling.sourceforge.net/UserGuide/attribute-custom-type.html)
    If it's not what you need, could you also give a little example?
Thats exactly what I need (except that I want an int instead of a bool) !

Thanks !

: )
  and I'll have a look at Arch when I find time ;)  Any idea on whether
  it wirks on sf?
What is nice about Arch is that is does not need any support on the
server side. Any remote file storage method will work, FTP, SFTP,
WebDav, NFS...

There is a ViewArch script to give the same functionality as ViewCVS.
You can also have free hosting on sourcecontrol.net as long as your
archive contain only free software. Sourcecontrol.net offers some
more Arch centric support like remote branch searching and they are in
the process to add website and release hosting too.

The Emacs vc-arch mode also made it's way in the Emacs CVS so we can
expect to see it in the next release.

Compared to Subversion, the other likely replacement for CVS, Arch
standout because it does not require special action on the server, it
already support symlinks and you have GPG signature of commits which
is quite an important feature with all the recent development server
compromises. Both support renaming and moving but Arch can detect it
without notifications without breaking history if you use tag-lines.
Thats quite a nice feature if you come up with the new name one of
these days...

; )

Get more information here:

http://wiki.gnuarch.org/

- --
Yannick Gingras "Let's say the docs present a simplified view of reality"
Coder for OBB : Obliquely Berserk Bookstore -- Larry Wall
http://OpenBeatBox.org

Loading...