Back to index

plone3  3.1.7
IPurgePolicy.py
Go to the documentation of this file.
00001 #########################################################################
00002 # Copyright (c) 2006 Gregoire Weber. 
00003 # All Rights Reserved.
00004 # 
00005 # This file is part of CMFEditions.
00006 # 
00007 # CMFEditions is free software; you can redistribute it and/or modify
00008 # it under the terms of the GNU General Public License as published by
00009 # the Free Software Foundation; either version 2 of the License, or
00010 # (at your option) any later version.
00011 # 
00012 # CMFEditions is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 # GNU General Public License for more details.
00016 # 
00017 # You should have received a copy of the GNU General Public License
00018 # along with CMFEditions; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00020 #########################################################################
00021 """Version Storage Purge Policy
00022 
00023 At save time control is handed over to the purge policy which has full 
00024 control over all versions from a resources history.
00025 
00026 $Id$
00027 """
00028 
00029 from Interface import Interface
00030 
00031 
00032 class IPurgePolicy(Interface):
00033     """Purge Policy
00034     
00035     Purge versions in a history according a policy. The methods declared
00036     are called by a ``IStorage`` implementation.
00037     """
00038 
00039     def beforeSaveHook(history_id, obj, metadata={}):
00040         """Purge Versions from the History According a Policy
00041         
00042         The Policy has full control over the whole history of the resource 
00043         and may decide to purge or alter versions in the history.
00044         
00045         Called before the current version is saved to the storage.
00046         The metadata passed is the metadata that was passed to the 
00047         ``save`` method.
00048         
00049         Return True if ``obj`` has to be saved by the ``IStorage`` 
00050         implementation. Return ``False`` if the object has to be discared.
00051         """
00052 
00053     def retrieveSubstitute(history_id, selector, default=None):
00054         """Return a selected version of an object or a substitute
00055         
00056         Called by the storage if the object to be retrieved was purged.
00057         Implement the policy in case a client tries to retrieve a purged
00058         version.
00059         
00060         Return a substitute of ``IVersionData`` type.
00061         """