0001-storage-move-load-dumps-into-their-own-class-methods.patch
wcs/qommon/storage.py | ||
---|---|---|
277 | 277 |
return cls.get_ids(ids) |
278 | 278 |
get_with_indexed_value = classmethod(get_with_indexed_value) |
279 | 279 | |
280 |
def get_filename(cls, filename, ignore_errors=False, ignore_migration=False):
|
|
280 |
def storage_load(cls, fd):
|
|
281 | 281 |
if get_publisher() and get_publisher().unpickler_class: |
282 | 282 |
unpickler = get_publisher().unpickler_class |
283 | 283 |
else: |
284 | 284 |
unpickler = pickle.Unpickler |
285 |
return unpickler(fd).load() |
|
286 |
storage_load = classmethod(storage_load) |
|
287 | ||
288 |
def get_filename(cls, filename, ignore_errors=False, ignore_migration=False): |
|
285 | 289 |
try: |
286 |
o = unpickler(file(filename)).load()
|
|
290 |
o = cls.storage_load(file(filename))
|
|
287 | 291 |
except IOError: |
288 | 292 |
if ignore_errors: |
289 | 293 |
return None |
... | ... | |
370 | 374 |
objects_dir = self.get_objects_dir() |
371 | 375 |
return os.path.join(objects_dir, fix_key(self.id)) |
372 | 376 | |
377 |
def storage_dumps(cls, object): |
|
378 |
return pickle.dumps(object) |
|
379 |
storage_dumps = classmethod(storage_dumps) |
|
380 | ||
373 | 381 |
def store(self, async=False): |
374 | 382 |
objects_dir = self.get_objects_dir() |
375 | 383 |
new_object = False |
... | ... | |
398 | 406 |
previous_object_value = self.get_filename(object_filename, |
399 | 407 |
ignore_errors=True, ignore_migration=True) |
400 | 408 | |
401 |
s = pickle.dumps(self)
|
|
409 |
s = self.storage_dumps(self)
|
|
402 | 410 |
atomic_write(object_filename, s, async) |
403 | 411 |
# update last modified time |
404 | 412 |
if os.path.exists(objects_dir): |
405 |
- |