Skip to content

Commit 9766c85

Browse files
author
khz
committed
fixed bug in dirty model handling. Now dirty is cleared correctly when rolling back changes
1 parent b6cceb2 commit 9766c85

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pythononwheels/start/models/modelobject.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ def rollback_dirty(self, name=None):
5151
Look at session.rollback() Bfor SQL or accordinug for mongoDB > 4 or other transation capable DBs
5252
"""
5353
if self.is_dirty:
54-
if name:
54+
if name in self.dirty:
5555
# only rollback attribute changes for name
5656
try:
5757
setattr(self, name, self.dirty[name]["value"])
58+
self.dirty.pop(name, None)
59+
# check if still elements in dirty
60+
if not self.dirty:
61+
self.is_dirty = False
5862
except Exception as e:
5963
print("ERROR Dirty rollback : {}".format(str(e)))
6064
# else: rollback all changes
@@ -183,7 +187,8 @@ def init_observers(self):
183187
self.__class__.observers_initialized = True
184188
self.__class__.observers.append(o)
185189
except Exception as e:
186-
print (" ... Found None: {}".format(str(e) ))
190+
self.__class__.observers_initialized = True
191+
#print (" ... Found None: {}".format(str(e) ))
187192

188193
def api(self):
189194
""" just for conveniance """

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
setup(name='pythononwheels',
11-
version='0.85b',
11+
version='0.852b',
1212
description='The simple, quick and easy generative web framework for python',
1313
long_description=long_description,
1414
classifiers=[

0 commit comments

Comments
 (0)