zopefoundation / zope.sqlalchemy

Integration of SQLAlchemy with transaction management
Other
32 stars 34 forks source link

`mark_changed` needs better docs, perhaps a better API #46

Closed jvanasco closed 3 years ago

jvanasco commented 4 years ago

After several hours of debugging, I finally solved a SqlAlchemy issue:

  1. mark_changed has an undocumented keep_session kwarg, which defaults to False
  2. mark_changed is unaware of how the session was registered (i.e. what the user intended keep_session to be)

My first suggestion is to update the docs/readme to point this out.

My second suggestion is to extend the ZopeTransactionEvents object to have it's own join_transaction and mark_changed functions, which invoke the global ones with the configured keep_session or anything else.

Since register returns the configured extension, this would allow a developer to invoke ext.mark_changed(dbSession) and preserve the value of keep_session. I'd be happy to generate a PR for this.