this is close to what i have - bitemporal versions of same object. 
i dont have relation to succesors/predecessor (this is assumed from 
object_id being same).

the practice shows there are attributes 
 - which u dont want to copy at all (dontcopy=list e.g. timestamps), 
 - which u dont want to copy in depth (dontcopyme=true, e.g. refs to 
external things), 
 - which u dont want the particular op to copy - e.g. because have 
been copied/changed by hand (dontcopy_now=list).
There also the case of explicit m2m assoc_objects which are handled 
differently of all else.

so it has to be some manual copy, or a very special setup of 
pickle-protocol-controls.

seems this is a common requirement, so i may put mine somewhere in 
dbcook/.

have fun
svil

On Wednesday 10 September 2008 11:39:43 Tim Jones wrote:
> Michael,
>
> Thanks for your reply.
>
> The use case is configuration management.
>
> We have complex (SQLAlchemy) objects with many relationships which
> we wish to up-version, i.e. we want an exact persistent copy
> (attribute values and relationships) of the original object, but
> with a different identity, which we will then modify.
>
> The original object and all its relationships should remain
> unchanged (other than a relationship to its successor version).
>
> We would want the copied object and all its relationships saved to
> the database before making changes to it.
>
> Regards,
>
> Tim
>
>
> 2008/9/9 Michael Bayer <[EMAIL PROTECTED]>
>
> > copy.copy() is going to have issues since you'd be copying the
> > _sa_state of the instance as well.   "copying" an object that is
> > SQLA mapped implies a particular use case in mind, depending on
> > this use case is what would determine how you get your "copy".
> >
> > Would you like to get a "copy" that is simply the same object
> > with the same identity, just as present in another session (in
> > which case use merge()) ?
> >
> > Or would you like to get a "copy" that is a transient (no
> > database identity) copy of that object, with all attributes
> > except primary key attributes copied over ?  ( in which case
> > you'd use a copy constructor which possibly uses mapping metadata
> > to traverse ) ?
> >
> > On Sep 9, 2008, at 2:16 PM, [EMAIL PROTECTED] wrote:
> > > u can try:
> > > from copy import copy
> > > dest = copy(src)
> > > it has pickle semantics, YMMV - i have not tried on SA objects.
> > > i use my own, see my post in this thread with some (complex)
> > > code:
> >
> > http://groups.google.com/group/sqlalchemy/tree/browse_frm/thread/
> >2369b78e0f8e21cb/4dd4979ca8501fba
> >
> > > On Tuesday 09 September 2008 18:59:09 picoplex wrote:
> > >> Is there a quick way to copy an object (including all its
> > >> relationships as well as its attributes)?
> > >>
> > >> Regards,
> > >>
> > >> Tim
>
> 


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to