From: Ivo v. d. W. <iv...@am...> - 2004-06-15 08:23:55
|
Hi All, I've been working with SQLObject for a while now and I love it. I have some remarks and questions after using it for a while though: Views: For what it's worth - I tried to create an SQLObject on top of a view (in PostgreSQL). This worked nicely for read operations, but updates don't work, partially because SQLObject assumes that Myview.id has a sequence myview_id_seq, while the original sequence is based on a different table on top of which the view is defined. Nothing serious, just something I tried. Perhaps someone has any real purpose for this :) SQL Inheritance: I tried creating a tree-like structure in SQL with a base 'Node' table and derived tables that need to be linked together. SQLObject can't really handle this. Lots of (SQL) ways to work around this, so no real problem, but at that time, my schema would have been more readable (and it would have allowed me to play with SQL inheritance) Inherticance (FAQ): It's not quite clear to me if the section 'How Does Inheritance Work?' in the FAQ relates to SQL Inheritance or to Python inheritance. Simple (single) inheritance in python works fine for me, i.e. class ParentRelation(SQLObject): parent = ForeignKey("Module") priority = IntCol(default=0) class ModuleParentRelation(ParentRelation): child = ForeignKey("Module") ModuleParentRelation.createTable() This creates just a module_parent_relation table, which is what I would expect. However, multiple inheritance (i.e. Mixins) doesn't work - the mixed in attributes just don't get generated in SQL, i.e. class foo: f = StringCol() class bar: b = StringCol() class blah(SQLObject, foo, bar) # or (foo, bar, SQLObject) bl = StringCol() Doesn't do the trick (come to think of it - should I derive foo and bar from SQLObject as well? I should give that a try) SQLBuilder: I'm using SQLBuilder to retrive childs of my nodes (which are ordered), something like: def Modules(self): return Module.select(AND(ModuleParentRelation.q.childID == Module.q.id, ModuleParentRelation.q.parentID == self.id), orderBy="module_parent_relation.priority") Why can't orderBy use the q attribute of the class? I.e. orderBy=ModuleParentRelatio.q.priority? (Or is there another way?) Now I need to lookup the generated tablename, and it looks less readable. Name genration: I noticed that all-caps class names result in a rather weird generated class name. I.e. 'FOO' will result in a class named 'fo_o'. This is most likely completely according to the defined naming scheme, but I wonder if anyone really wants this. All in all, a great tool, I enjoy it alot. Cheers Ivo -- Drs. I.R. van der Wijk -=- Korte Leidsedwarsstraat 12 Amaze Internet Services V.O.F. 1017 RC Amsterdam, NL -=- T +31-20-4688336 F +31-20-4688337 Zope/Plone/Content Management W http://www.amaze.nl E in...@am... Open Source Solutions W http://vanderwijk.info E iv...@am... Consultancy PGP http://vanderwijk.info/pgp |