|
2008-03-09
Tags: Programming SQLAlchemy has a new, easy declarative layerA transcript from the #sqlalchemy IRC channel <zzzeek_> deitarion: we just added a new declarative layer which removes a little of the verbosity, not sure if thats where you saw "too much boilerplate" <justsomedood> woot, declarative layer part of SA? So not an extension? <zzzeek_> its in ext/ <zzzeek_> we've had activemapper its just terrilby out of date <justsomedood> way out of date <zzzeek_> this is way smaller than activemapper <zzzeek_> its 90 lines <justsomedood> I ran into a lot of problems with it, and sent some fixes to johnathan but it ended up being too much work <zzzeek_> i doubt this one has any big problems <zzzeek_> since it does almost nothing :) <justsomedood> hehehe <Gedd> justsomedood: what kind of problems? <justsomedood> It deferred class loading / table creation to make sure all dependencies were met before it did, that didn't always work <justsomedood> I ran into cases where if I didn't define my classes in the correct order it would never create them, or get stuck in a loop <justsomedood> I haven't used it since 3.10-ish I think though <Gedd> ah ok <Gedd> that explains it :) <NandoFlorestan> zzzeek_, the synonym stuff in the declarative layer is sweet! <NandoFlorestan> I think this may be an Elixir killer <jek> nah <Gedd> NandoFlorestan: FWIW, Elixir handles synonyms too <NandoFlorestan> hmm, didnt know that. <zzzeek_> NandoFlorestan: elixir has a ton of stuff this does not <justsomedood> So on this one, when defining "complex" relations(), with a primaryjoin on a table/object that hasn't been defined yet you'd probably have to make that at the end with a class_mapper()? <zzzeek_> you can stick it on later, like User.someprop = relation(SomeOtherObject, priamryjoin=foo.c.bar==bat.c.foo) <zzzeek_> theres no class_mapper() needed here really since the class goes right to the mapper.....its also there as class.__mapper__ <justsomedood> k <justsomedood> cool <justsomedood> it would definitly condense my models and make them easier for others to read, and I wouldn't have to worry about the syntax changing <justsomedood> me likes <NandoFlorestan> that is why I like it: I already know the syntax |