Martijn Faassen wrote: > Hi there, > > I'm writing a doctest in which I include a MappedCollection subclass. In > my doctest, I create such a subclass:: > > >>> class Foo(MappedCollection): > ... pass > > Unfortunately later on, sqlalchemy.orm.collections.py has a check to > determine whether Foo is really a builtin, and if so, it fails to > instrument, here:: > > def _instrument_class(cls): > ... > # In the normal call flow, a request for any of the 3 basic collection > # types is transformed into one of our trivial subclasses > # (e.g. InstrumentedList). Catch anything else that sneaks in here... > if cls.__module__ == '__builtin__': > raise sa_exc.ArgumentError( > "Can not instrument a built-in type. Use a " > "subclass, even a trivial one.") > > Unfortunately, when Foo is 'cls', it will have __module__ set to > '__builtin__' even while Foo is not a builtin. > > I can work around this issue in the doctest by something something evil > like:: > > >>> Foo.__module__ = 'foo' > > Things then seem to work. > > Could the check somehow be modified to still find true builtins but not > those defined in a doctest?
Sure. Any suggestions for an alternate check? > I can also see this as being a doctest > problem; perhaps the __module__ should really be set to '__main__' in > them, but it might be easier to get it fixed here... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---