Projet

Général

Profil

0001-snapshots-store-snapshot-files-on-forms-update-36507.patch

Nicolas Roche, 12 décembre 2019 16:38

Télécharger (1,79 ko)

Voir les différences:

Subject: [PATCH 1/2] snapshots: store snapshot files on forms update (#36507)

 wcs/formdef.py        | 16 ++++++++++++++++
 wcs/qommon/storage.py |  3 +++
 2 files changed, 19 insertions(+)
wcs/formdef.py
1470 1470
        # chunk contains the fields.
1471 1471
        return pickle.dumps(object, protocol=2) + pickle.dumps(object.fields, protocol=2)
1472 1472

  
1473
    def snapshot(self):
1474
        return FormDefSnapshot(self)
1475

  
1473 1476

  
1474 1477
from .qommon.admin.emails import EmailsDirectory
1475 1478

  
......
1664 1667
    get_publisher_class().register_cronjob(CronJob(clean_unused_files,
1665 1668
        name='clean_unused_files',
1666 1669
        hours=[2], minutes=[0]))
1670

  
1671
class FormDefSnapshot(FormDef):
1672
    _names = 'formdefs.snapshots'
1673
    snapshot = None
1674

  
1675
    def __init__(self, formdef):
1676
        self.__dict__ = copy.deepcopy(formdef.__dict__)
1677
        del self._names  # restaure class attributes
1678
        self.id = "%s.%s" % (self.id,
1679
            time.strftime('%Y-%m-%d_%H-%M-%S', time.localtime()))
1680

  
1681
    def store():
1682
        pass
wcs/qommon/storage.py
577 577
        return pickle.dumps(object, protocol=2)
578 578

  
579 579
    def store(self, async_op=False):
580
        if getattr(self, 'snapshot', None):
581
            StorableObject.store(self.snapshot())
582

  
580 583
        objects_dir = self.get_objects_dir()
581 584
        new_object = False
582 585
        if self._filename:
583
-