[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-07 Thread Don Dwiggins
Marcin Krol wrote: >> if you're looking for state between requests you can use an HTTP session >> for that > > *SMACK* forehead... Right.. Mental block.. > >> and "lightweight" objects are great for those since they are >> easily serializable and use minimal space. > >> Im a little confused, d

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread az
> > one2many are the tricky ones - there's no "copy" as semantics, > > there's "move". > > Say again? I can't (shallow) copy one-to-many object to another? Or > do you mean: I can't copy it to another object, modify it and then > copy it back? shallow? if A points to B1, copying B1 to B2 is ok, b

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Michael Bayer
Marcin Krol wrote: > >> if you're looking for state between requests you can use an HTTP session >> for that > > *SMACK* forehead... Right.. Mental block.. > >>and "lightweight" objects are great for those since they are >> easily serializable and use minimal space. > >> Im a little confused, did

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Marcin Krol
> if you're looking for state between requests you can use an HTTP session > for that *SMACK* forehead... Right.. Mental block.. >and "lightweight" objects are great for those since they are > easily serializable and use minimal space. > Im a little confused, did you originally intend to persi

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Michael Bayer
Marcin Krol wrote: > > Michael Bayer wrote: >> sqlalchemy objects always log change events when things are modified. >> when i need a "throwaway" version of an object I often use a separate >> class for that, sometimes just a vanilla "object" subclass that I set >> attributes on, i.e. >> >> >> cla

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Marcin Krol
Hello az, thanks for answer, a...@svilendobrev.com wrote: > the copy can be a dummy non-db-aware - if that is ok in your case > > there's yet another option; u can just go all over the original > object, and on cancel do a rollback, and restore all changed stuff > back by hand (eventualy look

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Marcin Krol
Michael Bayer wrote: > sqlalchemy objects always log change events when things are modified. > when i need a "throwaway" version of an object I often use a separate > class for that, sometimes just a vanilla "object" subclass that I set > attributes on, i.e. > > > class Lightweight(object): >

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread az
the copy can be a dummy non-db-aware - if that is ok in your case there's yet another option; u can just go all over the original object, and on cancel do a rollback, and restore all changed stuff back by hand (eventualy looking at object-state's history). But this assumes short editing/single

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Michael Bayer
sqlalchemy objects always log change events when things are modified. when i need a "throwaway" version of an object I often use a separate class for that, sometimes just a vanilla "object" subclass that I set attributes on, i.e. class Lightweight(object): def __init__(self, **kw):

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread Marcin Krol
a...@svilendobrev.com wrote: > u'd better edit a new copy and on save copy all back into original > then commit that one, on cancel abandon the new one (but beware of > m2m relations if u have them). > all else isn't safe/nice IMO. To make it specific, should I do smth like: 1. on beginning of

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread az
u'd better edit a new copy and on save copy all back into original then commit that one, on cancel abandon the new one (but beware of m2m relations if u have them). all else isn't safe/nice IMO. On Wednesday 06 May 2009 17:25:47 Marcin Krol wrote: > Hello, > > I would like to implement typical