Re: [sqlalchemy] marking an object read-only / recursive expunge?

2015-07-23 Thread Jonathan Vanasco
So my code above is just completely wrong. This code actually does what one expects: def recursive_expunge(obj, dbSession): def _recursive_expunge(_obj): _instance_state = sqlalchemy.inspection.inspect(_obj) _mapper = _instance_state.mapper try:

Re: [sqlalchemy] marking an object read-only / recursive expunge?

2015-07-17 Thread Jonathan Vanasco
On Friday, July 17, 2015 at 2:46:42 PM UTC-4, Michael Bayer wrote: well then yeah you need to do your own thing :) i foolishly thought this was something others may have experienced ;) i'd use inspect(obj) to get the mapper.but also you might want to use cascade_iterator:

Re: [sqlalchemy] marking an object read-only / recursive expunge?

2015-07-17 Thread Mike Bayer
On 7/17/15 2:32 PM, Jonathan Vanasco wrote: editing the cascade isn't an option. well then yeah you need to do your own thing :) i'd use inspect(obj) to get the mapper.but also you might want to use cascade_iterator:

[sqlalchemy] marking an object read-only / recursive expunge?

2015-07-17 Thread Jonathan Vanasco
I'm updating our visual preview tool for edits, and ran into an issue. In order to best mimic the production view, I can't simply clone the objects any longer (they have way too many attributes and relationships) and must apply edits onto the real object. I'd like to ensure that changes

Re: [sqlalchemy] marking an object read-only / recursive expunge?

2015-07-17 Thread Mike Bayer
On 7/17/15 2:18 PM, Jonathan Vanasco wrote: I'm updating our visual preview tool for edits, and ran into an issue. In order to best mimic the production view, I can't simply clone the objects any longer (they have way too many attributes and relationships) and must apply edits onto the real

Re: [sqlalchemy] marking an object read-only / recursive expunge?

2015-07-17 Thread Jonathan Vanasco
editing the cascade isn't an option. for now this seems to work, though it's ugly. def recursive_expunge(obj, dbSession): def _recursive_expunge(_obj): if hasattr(_obj, '__mapper__'): for rel in obj.__mapper__.relationships: