B
Bruno Desthuilliers
George Sakkis a écrit :
This is a typical case of converting/validating data from the "outside
world" - something well covered by formencode.
Indeed. In fact, proper "type checking" would first require some
agreement on what's a "type"...
John Machin wrote:
(snip)
I have also a very recent real-world example to share, from the other
side of the fence this time. It's even worse because it's an error that
passes silently. Cut-down version follows:
@cherrypy.expose
def retrieve(self, **kwds):
queries = kwds['q']
rows = self._selectRows(*queries)
# more stuff
'q' here is a multiselect field that is binded to a list of selected
strings. Or so I thought, until someone noticed bizarre results in some
cases. Turns out that if you select a single item from the select box,
'q' is binded to a string instead of a list of length 1, so instead of
retrieving 'apple', she got back the results for 'a', 'p', 'p',
'l','e'.
This is a typical case of converting/validating data from the "outside
world" - something well covered by formencode.
Bottom line, type checking is a tricky business.
Indeed. In fact, proper "type checking" would first require some
agreement on what's a "type"...