Hi,

Background information: I am trying to implement functionality similar to 
the history_meta.py example 
(http://docs.sqlalchemy.org/en/rel_0_9/_modules/examples/versioned_history/history_meta.html).
 
I am listening for after_flush events and create an audit record and am 
having problems with association objects. Here is an example:

        class User(Auditable, self.Base, ComparableEntity):
            __tablename__ = 'usertable'
            id = Column(Integer, primary_key=True)
            name = Column(String)
            keywords = association_proxy('assocs', 'keyword')

        class Keyword(Auditable, self.Base, ComparableEntity):
            __tablename__ = 'keywordtable'
            id = Column(Integer, primary_key=True)
            word = Column(String)

        class UserKeyword(Auditable, self.Base, ComparableEntity):
            __tablename__ = 'userkeywordtable'
            user_id = Column(Integer, ForeignKey("usertable.id"),
                             primary_key=True)
            keyword_id = Column(Integer, ForeignKey("keywordtable.id"),
                                primary_key=True)
            user = relationship(User, 
                                backref=backref("assocs",
                                                cascade="all, 
delete-orphan"))
            keyword = relationship(Keyword)
            def __init__(self, keyword=None, user=None):
                self.user = user
                self.keyword = keyword


        apple = Keyword(word='apple')
        pear = Keyword(word='pear')
        bob = User(name='bob')
        bob.keywords = [apple, pear]
        sess.add(bob)
        sess.commit()

        bob.keywords.remove(apple)   <====== this is when my question is 
about
        sess.commit()
        
When we remove the keyword, it marks the UserKeyword association object is 
"dirty" instead of "deleted". Why is that? Since the row is being removed, 
I would expect it to be marked as "deleted", so that I could make an audit 
record indicating it was deleted.

Thanks,
Steve

-- 
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