diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-25 00:17:51 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-25 00:17:51 +0000 |
| commit | fcbd4f153980384089ce8d519607a1db8e7e8838 (patch) | |
| tree | 864dce90ec6b0ce420bc6f055bb7e17f667482f1 /lib/sqlalchemy/mapping | |
| parent | 03bb7a9641eb936fc6f5867a9df57f348aa674c9 (diff) | |
| download | sqlalchemy-fcbd4f153980384089ce8d519607a1db8e7e8838.tar.gz | |
added expunge() method to objectstore
correction in attributes reset_history to really reset in all cases
added unit tests testing refresh()/expire() bug that was fixed by reset_history thing
Diffstat (limited to 'lib/sqlalchemy/mapping')
| -rw-r--r-- | lib/sqlalchemy/mapping/objectstore.py | 9 | ||||
| -rw-r--r-- | lib/sqlalchemy/mapping/unitofwork.py | 7 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/sqlalchemy/mapping/objectstore.py b/lib/sqlalchemy/mapping/objectstore.py index f978d16f7..6b3d7f034 100644 --- a/lib/sqlalchemy/mapping/objectstore.py +++ b/lib/sqlalchemy/mapping/objectstore.py @@ -166,6 +166,10 @@ class Session(object): for o in obj: global_attributes.trigger_history(o, lambda: refresh(o)) + def expunge(self, *obj): + for o in obj: + self.uow.expunge(obj) + def register_clean(self, obj): self._bind_to(obj) self.uow.register_clean(obj) @@ -252,7 +256,10 @@ def expire(*obj): """invalidates the data in the given objects and sets them to refresh themselves the next time they are requested.""" get_session().expire(*obj) - + +def expunge(*obj): + get_session().expunge(*obj) + def delete(*obj): """registers the given objects as to be deleted upon the next commit""" s = get_session().delete(*obj) diff --git a/lib/sqlalchemy/mapping/unitofwork.py b/lib/sqlalchemy/mapping/unitofwork.py index 2dc524897..1e5388933 100644 --- a/lib/sqlalchemy/mapping/unitofwork.py +++ b/lib/sqlalchemy/mapping/unitofwork.py @@ -104,6 +104,11 @@ class UnitOfWork(object): """returns True if the given key is present in this UnitOfWork's identity map.""" return self.identity_map.has_key(key) + def expunge(self, obj): + """removes this object completely from the UnitOfWork, including the identity map, + and the "new", "dirty" and "deleted" lists.""" + self._remove_deleted(obj) + def _remove_deleted(self, obj): if hasattr(obj, "_instance_key"): del self.identity_map[obj._instance_key] @@ -119,7 +124,7 @@ class UnitOfWork(object): del self.new[obj] except KeyError: pass - self.attributes.commit(obj) + #self.attributes.commit(obj) self.attributes.remove(obj) def _validate_obj(self, obj): |
