This could replace is_selectable and also isinstance calls, so instead of code like
if arg is not None and isinstance(arg, sql.Selectable):
return self.select_statement(arg, **kwargs)
else:
return self.select_whereclause(whereclause=arg, **kwargs)
you'd have something like
try:
s = arg._selectable_()
except AttributeError:
return self.select_whereclause(whereclause=arg, **kwargs)
else:
return self.select_statement(s, **kwargs)
Like __iter__, most _selectable_ methods would just return self, but this would allow things that aren't a subclass of Selectable yet know how to make/get one to interact with the rest of SA. Like, say, SqlSoup's reflected classes.
(It's also somewhat more pythonic to my way of thinking, but I know that some people don't like that word. :)
I count 10 isinstance calls like the above and 5 references to is_selectable so it looks feasible from here. Would you accept a patch for this, Michael?
--
Jonathan Ellis
http://spyced.blogspot.com
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users