0001-sql-don-t-update-when-Evolution-object-is-unchanged-.patch
wcs/formdata.py | ||
---|---|---|
138 | 138 | |
139 | 139 | |
140 | 140 |
class Evolution: |
141 |
who = None |
|
142 |
status = None |
|
143 |
time = None |
|
144 |
last_jump_datetime = None |
|
145 |
comment = None |
|
146 |
parts = None |
|
141 |
_who = None |
|
142 |
_status = None |
|
143 |
_time = None |
|
144 |
_last_jump_datetime = None |
|
145 |
_comment = None |
|
146 |
_parts = None |
|
147 | ||
148 |
def __init__(self): |
|
149 |
self._changed = False |
|
150 | ||
151 |
@property |
|
152 |
def who(self): |
|
153 |
return self._who |
|
154 | ||
155 |
@who.setter |
|
156 |
def who(self, value): |
|
157 |
self._changed = True |
|
158 |
self._who = value |
|
159 | ||
160 |
@property |
|
161 |
def status(self): |
|
162 |
return self._status |
|
163 | ||
164 |
@status.setter |
|
165 |
def status(self, value): |
|
166 |
self._changed = True |
|
167 |
self._status = value |
|
168 | ||
169 |
@property |
|
170 |
def time(self): |
|
171 |
return self._time |
|
172 | ||
173 |
@time.setter |
|
174 |
def time(self, value): |
|
175 |
self._changed = True |
|
176 |
self._time = value |
|
177 | ||
178 |
@property |
|
179 |
def last_jump_datetime(self): |
|
180 |
return self._last_jump_datetime |
|
181 | ||
182 |
@last_jump_datetime.setter |
|
183 |
def last_jump_datetime(self, value): |
|
184 |
self._changed = True |
|
185 |
self._last_jump_datetime = value |
|
186 | ||
187 |
@property |
|
188 |
def comment(self): |
|
189 |
return self._comment |
|
190 | ||
191 |
@comment.setter |
|
192 |
def comment(self, value): |
|
193 |
self._changed = True |
|
194 |
self._comment = value |
|
195 | ||
196 |
@property |
|
197 |
def parts(self): |
|
198 |
return self._parts |
|
199 | ||
200 |
@parts.setter |
|
201 |
def parts(self, value): |
|
202 |
self._changed = True |
|
203 |
self._parts = value |
|
147 | 204 | |
148 | 205 |
def __init__(self, formdata=None): |
149 | 206 |
self._formdata = formdata # formdata cache |
... | ... | |
231 | 288 |
data['parts'] = parts |
232 | 289 |
return data |
233 | 290 | |
234 |
# don't pickle _formata cache |
|
291 |
# don't pickle _formata cache, and keep compatibility with old non-private keys
|
|
235 | 292 |
def __getstate__(self): |
236 | 293 |
odict = self.__dict__.copy() |
237 | 294 |
if '_formdata' in odict: |
238 | 295 |
del odict['_formdata'] |
239 | 296 |
if '_display_parts' in odict: |
240 | 297 |
del odict['_display_parts'] |
298 |
for k in ['who', 'status', 'time', 'last_jump_datetime', 'comment', 'parts']: |
|
299 |
if '_' + k in odict: |
|
300 |
odict[k] = odict['_' + k] |
|
301 |
del odict['_' + k] |
|
302 |
if '_changed' in odict: |
|
303 |
del odict['_changed'] |
|
241 | 304 |
return odict |
242 | 305 | |
306 |
# migrate from non-private keys to private keys |
|
307 |
def __setstate__(self, odict): |
|
308 |
for k in ['who', 'status', 'time', 'last_jump_datetime', 'comment', 'parts']: |
|
309 |
if k in odict: |
|
310 |
odict['_' + k] = odict[k] |
|
311 |
del odict[k] |
|
312 |
self.__dict__ = odict |
|
313 | ||
243 | 314 |
@property |
244 | 315 |
def datetime(self): |
245 | 316 |
return datetime.datetime(*self.time[:6]) |
wcs/sql.py | ||
---|---|---|
2441 | 2441 |
o.time = o.time.timetuple() |
2442 | 2442 |
if row[6]: |
2443 | 2443 |
o.parts = pickle_loads(row[6]) |
2444 |
# Reset the changed state of the object |
|
2445 |
o._changed = False |
|
2444 | 2446 |
return o |
2445 | 2447 | |
2446 | 2448 |
def set_evolution(self, value): |
... | ... | |
2596 | 2598 |
for evo in self._evolution: |
2597 | 2599 |
sql_dict = {} |
2598 | 2600 |
if hasattr(evo, '_sql_id'): |
2601 |
# don't update when nothing changed. |
|
2602 |
if not getattr(evo, '_changed', True): |
|
2603 |
continue |
|
2604 | ||
2599 | 2605 |
sql_dict.update({'id': evo._sql_id}) |
2600 | 2606 |
sql_statement = ( |
2601 | 2607 |
'''UPDATE %s_evolutions SET |
2602 |
- |