On 23 Ott, 19:19, Mike Conley <mconl...@gmail.com> wrote:
> > I'm trying to automatically build a shallow copy of a SA-mapped
> > object.. At the moment my function is just:
>
> > newobj = src.__class__()
> > for prop in class_mapper(src.__class__).iterate_properties:
> >    setattr(newobj, prop.key, getattr(src, prop.key))
>
> > but I'm having troubles with lazy relations... Obviously getattr
> > triggers the lazy loading, but since I don't need their values right
> > away, I'd like to just copy the "this should be lazy loaded"-state of
> > the attribute... Is this possible?
>
> I did something similar. I iterated on class_mapper().columns to get the
> attributes to populate. That approach skipped all the relations, and in my
> case was exactly what I wanted


I see, but I need a proper shallow copy instead, with every
attribute.. Is there no way? :/

--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to