From: Ian B. <ia...@co...> - 2004-01-20 23:38:53
|
Ian Sparks wrote: >> Ian Bicking wrote on Monday, January 19, 2004 10:38 PM : By using >> descriptors, introspection should become a bit easier -- or at >> least more uniform with respect to other new-style classes. Various >> class-wide indexes of columns will still be necessary, but these >> should be able to remain mostly private. > > Sorry to pull out just this one part of your plan but its not clear > to me how you do introspection on current table classes to say, find > out what columns a table has. This would be useful for generating > editing web-pages for SO Objects for instance. Being able to walk > joins would also be helpful so that you could have master/detail > relationships or populate combo-boxes of all possible values for a > field. Well, right now you can look at _columns, which should have most of the stuff you'd want. Ideally the SQLMeta object (in this redesign) would have a clear set of methods for doing introspection. For this case, I think it's better for the object to introspect itself, and that you add a method to it like .fields() or something. Of course, you still need some form of introspection, even if the object is introspecting itself. I think for joins, you are really thinking of ForeignKey (or maybe RelatedJoin, I suppose), where you want to find all the possible objects that this object could point to. In this case I think you want to look at the ForeignKey object (which should be available through _columns), and do something like SQLObject.findClass(ForeignKeyColObj.foreignKey).search() to get the possible options. Ian |