uh, sure. how about __selectable__ though, whats one underscore ?On Jul 7, 2006, at 1:24 PM, Jonathan Ellis wrote: I had an idea for a selectable protocol for SA similar to Python's iterator protocol -- a _selectable_ method that returns a Selectable, similar to how __iter__ returns an iterator where relevant.
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.comUsing 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 _______________________________________________ Sqlalchemy-users mailing list |
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