On Wed, Dec 3, 2008 at 7:03 PM, Oleg Broytmann <[EMAIL PROTECTED]> wrote: > On Wed, Dec 03, 2008 at 06:47:07PM -0500, inhahe wrote: >> ----tablestest.py--- >> from sqlobject import * >> class Houses(SQLObject): >> pass >> class Bathrooms(SQLObject): >> house = ForeignKey("Houses") >> index1 = DatabaseIndex(house) >> >> ----the file i invoke--- >> from sqlobject import * >> from connectstr import connectstr >> connection = connectionForURI(connectstr) >> sqlhub.processConnection = connection >> import tablestest >> for name in dir(tablestest): >> obj = getattr(tablestest, name) >> if hasattr(obj, "createTable"): >> print obj >> obj.createTable() > > dir() returns objects in a random order. It could be that dir() returns > 'Bathrooms' before 'Houses', and MySQL reports it cannot create a FOREIGN > KEY that points to a non-existing table. > Solution: create the tables in the proper order - Houses first.
Oh, good point, thanks. Although I installed the latest bugfix release and I don't have the problem anymore. Although I'm a little confused about how the various releases work and why the latest bugfix version is 0.7 when I previously had 0.11. It was definitely doing the 'Bathrooms' table first though. The thing is I don't really know how I should do this. I don't think the documentation sufficiently explains how we should initially make the the tables vs. just have the classes defined so we can use them. I don't want to have to make two files, each defining each class, one for creating the tables and one for using them, and then have to update both files every time I change a column. So that's why I tried it the way I did. But like you said, dir can return them in any order. So what's a good way to do this? Thanks ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss