On Oct 17, 2011, at 11:38 AM, Russ wrote:

> All the declarative examples have DeclarativeBase as the first/left base 
> class.  Does it need to be?  I've swapped it in several code locations and 
> experimented and it seems to be fine, but there's a lot going on with 
> declarative and I'm vaguely paranoid about messing it up subtly by altering 
> the MRO.
> 
> ie: This is "normal", and is how all declarative examples are done:
> 
> class Foo(Base, MyMixin):
>     #snip
> 
> but is this also ok, or will it cause issues somehow?
> 
> class Foo2(MyMixin, Base):
>     #snip

The MRO basically matters as much as it matters in any case.   If your mixin 
has an attribute that's not in a prior class within the MRO, that's the 
attribute that wins.   Declarative scans through the whole MRO at startup but 
pretty much keeps things the way they work anyway (deviations from that would 
be bugs).

Actually I usually put the mixins first, because you're overriding whatever is 
the "base".  I should even change the docs in that regard, it's weird that they 
don't use that convention.   Looking now it's actually fairly awkward the way 
it is.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
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.

Reply via email to