Support for old-style classes in inheritance tree

7 views
Skip to first unread message

Malthe Borch

unread,
Jul 22, 2008, 10:36:30 AM7/22/08
to sqlal...@googlegroups.com
Currently, classes that inherit from old-style classes are not supported
on two accounts:

1) They do not provide the __subclasses__-method
2) It's not possible to make a weak reference to them

Below is a patch that effectively ignores them:

Index: lib/sqlalchemy/util.py
===================================================================
--- lib/sqlalchemy/util.py (revision 4964)
+++ lib/sqlalchemy/util.py (working copy)
@@ -401,6 +401,8 @@
while process:
c = process.pop()
for b in [_ for _ in c.__bases__ if _ not in hier]:
+ if isinstance(b, types.ClassType):
+ continue
process.append(b)
hier.add(b)
if c.__module__ == '__builtin__':

Would it be reasonable to support legacy code this way?

\malthe

Michael Bayer

unread,
Jul 22, 2008, 10:46:41 AM7/22/08
to sqlalchemy
you mean as mixins, right? this has been brought up before. I leave
it up to Jason on this one since he's done the most work with class
instrumentation.

Malthe Borch

unread,
Jul 23, 2008, 5:27:48 AM7/23/08
to sqlal...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages