formulator, xml and python 2.3
Clemens Robbenhaar <robbenhaar-WaVJUzJ3u31Wk0Htik3J/[email protected]> Sat, 24 Jan 2004 22:41:41 +0100
| Newsgroups | gmane.comp.web.zope.formulator.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Sebastien, > > Something changed between python 2.2 and python 2.3. > in python 2.2 : 1==1 returns 1 > in python 2.3 : 1==1 returns True > Yep, that the introduction of BooleanType or so ... > So in python 2.2 checkbox fields were returning 0 or 1, and with python > 2.3 it returns true or false, with give errors when it is commited into > the url (because it expect an int). > > I had to do this for BooleanValidator: > > validate(self, field, key, REQUEST): > result = not not REQUEST.get(key, 0) > if result==True: > return 1 > else: > return 0 Hm, what do You mean with "commiting to an url"? So far I cannot produce any error and this stayed away "fixing" bugs the BooleanValidator I did not see ... > > And it is even worse when we do a formToXML and after an XMLToForm. > This is what I had without any modification to BooleanValidator. > > formToXML returns : ...<required type>True</required>... > then XMLToForm thinks that the field required is a string with the value > "True". I can reproduce this without problems :) > > By the same time, when we set a method for a field value, the xml output > may set a type, like type="method", and the name of the method. If we > don't do that, the xml output is like this : > <list_method><Method instance at 44a17a40></list_method> > > I join with this mail the patch I have applied for xml. Thanks for the patch! I have put in in the CVS (with a minor quirk, so it still runs with python 2.1.3). Unit tests now pass with Zope2.6.1/python2.1.3 and Zope2.7-rc4/python2.3.2 Please everybody test if this does not break something else ;-) Cheers, Clemens