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: http://docs.sqlalchemy.org/en/rel_1_0/orm/mapping_api.html?highlight=cascade_iterator#sqlalchemy.orm.mapper.Mapper.cascade_iterator

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:
                        try:
                            dbSession.expunge(rel)
                        except sqlalchemy.orm.exc.UnmappedInstanceError:
                            pass
            _recursive_expunge(obj)
        recursive_expunge(postingObject, self.request.dbSession.writer)

--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to