On Tuesday 25 September 2007 05:43:40 Huy Do wrote:
> Michael Bayer wrote:
> > On Sep 24, 2007, at 11:48 AM, Huy Do wrote:
> >> Hi,
> >>
> >> Is it possible to get SA ORM to return plain python objects
> >> (with eagerloaded relations and all) but without any attribute
> >> instrumentation
> >> (or anything else magically added by SA).
> >
> > not really. unless you remove the instrumentation from the
> > classes themselves afterwards (a one way operation).
>
> Any pointers on how to do this ? to the whole object hierachy.
just grab the objects __dict__, and make any class out of it. u'll
need 2 parralel class hierarchies, or maybe one parasit hierarhcy
hanging on the other..
e.g.
class Aplain:
methods...
def undress(self):
r = self.__class__(); r.__dict__.update( self.__dict__); return r
class Aplain4SA(Aplain): pass
m = mapper( Aplain4SA, ...)
...
def myquery( query):
for q in query: yield q.undress()
and use myquery() as wrapper for all session.query(..)
the overhead would be one generator..
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---