• Barry Warsaw's avatar
    Two simple, but working (for FileStorage at least ;), pack tests. · 377fc848
    Barry Warsaw authored
    checkPackAllRevisions(): Create an object and store three different
    revisions of the object.  Before packing, check to make sure all three
    revisions can be loaded.  After packing, make sure all revisions are
    gone (since they were not referenced by the root object, they are
    garbage).
    
    checkPackJustOldRevisions(): Same as above, but this time create a
    root object and a link from the root object to the persistent object.
    Then store three different revisions of the persistent object and make
    sure all three revisions can be loaded.  After packing, make sure the
    first two revisions are gone, but that the third revision (and the
    root object) can be loaded.
    
    Other changes:
    
    - Add a ZERO global
    
    - Add a Root class which does /not/ have a getoid() method (so its
      state will be pickled as normal, but attributes that point to
      `persistent' objects will be serialized as persistent ids).
    
    - dumps(): In getpersid(), return None if the object has no getoid()
      method.  This ensures that the root object will get pickled
      correctly as described above.
    
    - _newobj(), _makeloader(): Move these into a common base class called
      PackableStorageBase.  This base class also maintains the cache of
      persistent ids to Object instances, for unpickling.
    
    - PackableStorage is the derived class that contains the actual tests.
    377fc848
PackableStorage.py 7.68 KB