dahlia / sqlalchemy-imageattach

SQLAlchemy extension for attaching images to entities.
https://sqlalchemy-imageattach.readthedocs.io/
MIT License
116 stars 25 forks source link

Implicit Contexts with Pyramid #28

Open andrewjburnett opened 9 years ago

andrewjburnett commented 9 years ago

I am running into an issue when attempting to use implicit contexts within a Pyramid application.

Using Pyramid's built-in BeforeRender event I can call the push_store_context function at the beginning of my request/response lifecycle - this works fine.

However, when using either the finished callback or response callbacks to pop the context at the end of the request I encounter an "IndexError: pop from empty list." I have checked my code to make sure all of the "with store_context(store):" implementations have been removed. Nonetheless, the error still occurs. Does this have something to do with how the contexts are managed internally by sqlalchemy-imageattach? Maybe the context has been emptied by the time the pop_store_context function is being called by the finished_callback at the VERY end of the request/response cycle.