Moved proxy dict listener to global scope

This commit is contained in:
Konsta Vesterinen
2013-05-30 15:11:22 +03:00
parent 0db35f3f67
commit b8b4785cde
3 changed files with 15 additions and 5 deletions

View File

@@ -4,6 +4,12 @@ Changelog
Here you can see the full list of changes between each SQLAlchemy-Utils release.
0.12.3 (2013-05-30)
^^^^^^^^^^^^^^^^^^^
- Proxy dict expiration listener from function scope to global scope
0.12.2 (2013-05-29)
^^^^^^^^^^^^^^^^^^^

View File

@@ -24,7 +24,7 @@ class PyTest(Command):
setup(
name='SQLAlchemy-Utils',
version='0.12.2',
version='0.12.3',
url='https://github.com/kvesteri/sqlalchemy-utils',
license='BSD',
author='Konsta Vesterinen',

View File

@@ -59,10 +59,6 @@ def proxy_dict(parent, collection_name, mapping_attr):
try:
parent._proxy_dicts
except AttributeError:
def expire_proxy_dicts(target, context):
target._proxy_dicts = {}
sa.event.listen(parent.__class__, 'expire', expire_proxy_dicts)
parent._proxy_dicts = {}
try:
@@ -74,3 +70,11 @@ def proxy_dict(parent, collection_name, mapping_attr):
mapping_attr
)
return parent._proxy_dicts[collection_name]
def expire_proxy_dicts(target, context):
if hasattr(target, '_proxy_dicts'):
target._proxy_dicts = {}
sa.event.listen(sa.orm.mapper, 'expire', expire_proxy_dicts)