[SQLObject] .get(int) vs. .get(string)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Hendrik M. <he...@ma...> - 2004-03-26 09:10:37
|
Hello everyone, ---cut--- >>> from Crop.Data.User import User >>> u1 = User.get(1) >>> u2 = User.get('1') >>> u1 == u2 False ---cut--- Is this by design? I was expecting SQLObject to either return the same object instance *or* raise an exception when passing the string. Background: I'm currently using SQLObject with CherryPy (a Python web application framework, www.cherrypy.org). CherryPy receives GET/POST parameters as strings, so when I want to use them to fetch an SQLObject, I have to convert them to ints first: u = User.get(int(id)) It's not much of a problem, but it's really hard to miss, since SQLObject simply returns a different object representing the same data. The User class is a simple SQLObject derived class with no "funky" features. Currently using SQLObject from SVN, revision 79. Thanks, Hendrik -- http://blog.mans.de |