I usually traverse recursively through __subclasses__().

On Sep 5, 2014, at 10:49 AM, Alex Grönholm <alex.gronh...@nextday.fi> wrote:

> Hm not so dumb actually, because __subclasses__ only lists immediate 
> subclasses. Getting all the mapped classes would involve more work that way. 
> So my preferred method remains this:
> 
> def get_all_mapped_classes():
>     return [cls for cls in Base._decl_class_registry.values() if 
> isinstance(cls, type)]
> 
> 
> perjantai, 5. syyskuuta 2014 17.19.21 UTC+3 Alex Grönholm kirjoitti:
> You're right, I'm dumb. I should've just used __subclasses__ and be done with 
> it.
> The use case is that I have a client-server app and I build a list of all 
> classes for the client so the client knows which column types to use in 
> tables. It's also used for automatically generating the column/relationship 
> list on the client in the search dialog. So I won't have to make code changes 
> to the client when I alter the model on the server.
> 
> perjantai, 5. syyskuuta 2014 17.13.10 UTC+3 Michael Bayer kirjoitti:
> well it's not set to be mapped until after the setup part of it.   
> 
> if you want to get every class whether mapped or not, maybe use 
> Base.__subclasses__() ?
> 
> What's the use case where you need the abstract base in the decl class 
> registry?  it's not really something you'd want to refer to in a 
> relationship().
> 
> 
> 
> On Sep 5, 2014, at 9:56 AM, Alex Grönholm <alex.g...@nextday.fi> wrote:
> 
>> Thanks. I've filed an issue at Bitbucket.
>> 
>> A follow-up question: Why are abstract base classes not present in the 
>> declarative class registry? Or is there another way to get all the mapped 
>> classes besides iterating over Base._decl_class_registry?
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sqlalchemy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to sqlalchemy+...@googlegroups.com.
>> To post to this group, send email to sqlal...@googlegroups.com.
>> Visit this group at http://groups.google.com/group/sqlalchemy.
>> For more options, visit https://groups.google.com/d/optout.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to