Question about commit in revision 3809

觀看次數:10 次
跳至第一則未讀訊息

Matt Wilson

未讀,
2007年12月5日 上午10:41:335/12/2007
收件者︰ TurboGears Trunk
Revision 3809 made this change to the testutil DBTest class

$ svn diff --diff-cmd=diff -r PREV:HEAD testutil.py
Index: testutil.py
===================================================================
--- testutil.py (revision 3757)
+++ testutil.py (revision 3809)
@@ -159,13 +159,20 @@
class DBTest(unittest.TestCase):
model = None

+ def _get_soClasses(self):
+ try:
+ return [self.model.__dict__[x] for x in
self.model.soClasses]
+
+ except AttributeError:
+ return self.model.__dict__.values()
+
def setUp(self):
if not self.model:
self.model = get_model()
if not self.model:
raise "Unable to run database tests without a model"

- for item in self.model.__dict__.values():
+ for item in self._get_soClasses():
if isinstance(item, types.TypeType) and issubclass(item,
sqlobject.SQLObject) and item != sqlobject.SQLObject
\
and item != InheritableSQLObject:
@@ -173,7 +180,7 @@

def tearDown(self):
database.rollback_all()
- for item in self.model.__dict__.values():
+ for item in self._get_soClasses():
if isinstance(item, types.TypeType) and issubclass(item,
sqlobject.SQLObject) and item != sqlobject.SQLObject
\
and item != InheritableSQLObject:

In the teardown case, shouldn't the tables be deleted in the reversed
order, so that the dependent tables are destroyed before the tables
that they depend on?

Florent Aide

未讀,
2007年12月5日 下午4:18:055/12/2007
收件者︰ turbogea...@googlegroups.com
> In the teardown case, shouldn't the tables be deleted in the reversed
> order, so that the dependent tables are destroyed before the tables
> that they depend on?

A dictionnary is not ordered so the teardown was not ordered before
this commit either...
Does this provoke problems for you?

Matt Wilson

未讀,
2007年12月6日 下午4:24:046/12/2007
收件者︰ TurboGears Trunk
I understand that dictionaries don't keep keys in order. However, the
self.model.soClasses object is not a dictionary. You can use
soClasses to force SQLObject to create your tables in a certain order.

Matt

Matt Wilson

未讀,
2008年1月11日 下午12:00:5111/1/2008
收件者︰ TurboGears Trunk
I made a trac ticket with a suggestion for how to fix here:
http://trac.turbogears.org/ticket/1674
回覆所有人
回覆作者
轉寄
0 則新訊息