Back to index

plone3  3.1.7
interfaces.py
Go to the documentation of this file.
00001 ##################################################################
00002 #
00003 # (C) Copyright 2006 ObjectRealms, LLC
00004 # All Rights Reserved
00005 #
00006 # This file is part of iterate.
00007 #
00008 # iterate is free software; you can redistribute it and/or modify
00009 # it under the terms of the GNU General Public License as published by
00010 # the Free Software Foundation; either version 2 of the License, or
00011 # (at your option) any later version.
00012 #
00013 # iterate is distributed in the hope that it will be useful,
00014 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 # GNU General Public License for more details.
00017 #
00018 # You should have received a copy of the GNU General Public License
00019 # along with CMFDeployment; if not, write to the Free Software
00020 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 ##################################################################
00022 """
00023 $Id: interfaces.py 1811 2007-02-06 18:40:02Z hazmat $
00024 """
00025 
00026 from zope.interface import Interface, Attribute
00027 from zope import schema
00028 
00029 from zope.component.interfaces import IObjectEvent
00030 from plone.locking.interfaces import LockType
00031 
00032 from Products.Archetypes.interfaces import IReferenceable, IReference
00033 
00034 #################################
00035 ## Marker interface
00036 
00037 class IIterateAware( IReferenceable ):
00038     """An object that can be used for check-in/check-out operations.
00039     """
00040 
00041 #################################
00042 ## Lock types
00043 
00044 ITERATE_LOCK = LockType( u'iterate.lock', stealable=False, user_unlockable=False )
00045 
00046 #################################
00047 ## Exceptions
00048 
00049 class CociException( Exception ):
00050     pass
00051 
00052 class CheckinException( CociException ):
00053     pass
00054 
00055 class CheckoutException( CociException ):
00056     pass
00057 
00058 class ConflictError( CheckinException ):
00059     pass
00060 
00061 
00062 #################################
00063 # Annotation Key
00064 annotation_key = "ore.iterate"
00065 
00066 class keys( object ):
00067     # various common keys
00068     checkout_user = "checkout_user"
00069     checkout_time = "checkout_time"
00070 
00071 
00072 
00073 #################################
00074 ## Event Interfaces
00075 
00076 class ICheckinEvent( IObjectEvent ):
00077     """ a working copy is being checked in, event.object is the working copy, this
00078     message is sent before any mutation/merge has been done on the objects
00079     """
00080 
00081     baseline = Attribute("The Working Copy's baseline")
00082     relation = Attribute("The Working Copy Archetypes Relation Object")
00083     checkin_message = Attribute("checkin message")
00084     
00085 class IAfterCheckinEvent( IObjectEvent ):
00086     """ sent out after an object is checked in """
00087 
00088     checkin_message = Attribute("checkin message")
00089 
00090 class IBeforeCheckoutEvent( IObjectEvent ):
00091     """ sent out before a working copy is created """
00092     
00093 class ICheckoutEvent( IObjectEvent ):
00094     """ an object is being checked out, event.object is the baseline """
00095 
00096     working_copy = Attribute("The object's working copy")
00097     relation = Attribute("The Working Copy Archetypes Relation Object")
00098     
00099 class ICancelCheckoutEvent( IObjectEvent ):
00100     """ a working copy is being cancelled """
00101     
00102     baseline = Attribute("The working copy's baseline")
00103 
00104 class IWorkingCopyDeletedEvent( IObjectEvent ):
00105     """ a working copy is being deleted, this gets called multiple times at different
00106     states. so on cancel checkout and checkin operations, its mostly designed to
00107     broadcast an event when the user deletes a working copy using the standard
00108     container paradigms.
00109     """
00110     
00111     baseline = Attribute("The working copy baseline")
00112     relation = Attribute("The Working Copy Archetypes Relation Object")    
00113     
00114 #################################
00115 # Content Marker Interfaces
00116 
00117 class IIterateManagedContent ( Interface ):
00118     """Any content managed by iterate - normally a sub-interface is
00119     applied as a marker to an instance.
00120     """
00121 
00122 class IWorkingCopy( IIterateManagedContent ):
00123     """A working copy/check-out
00124     """
00125 
00126 class IBaseline( IIterateManagedContent ):
00127     """A baseline
00128     """
00129 
00130 class IWorkingCopyRelation( IReference ):
00131     """A relationship to a working copy
00132     """
00133 
00134 #################################
00135 ## Working copy container locator
00136 
00137 class IWCContainerLocator( Interface ):
00138     """A named adapter capable of discovering containers where working
00139     copies can be created.
00140     """
00141     
00142     available = schema.Bool(title=u"Available", description=u"Whether location will be available.")
00143 
00144     title = schema.TextLine(title=u"Title", description=u"Title of this location")
00145     
00146     def __call__():
00147         """Return a container object, or None if available() is False
00148         """
00149 
00150 #################################
00151 ## Interfaces
00152 
00153 class ICheckinCheckoutTool( Interface ):
00154 
00155     def allowCheckin( content ):
00156         """
00157         denotes whether a checkin operation can be performed on the content.
00158         """
00159         
00160     def allowCheckout( content ):
00161         """
00162         denotes whether a checkout operation can be performed on the content.        
00163         """
00164 
00165     def allowCancelCheckout( content ):
00166         """
00167         denotes whether a cancel checkout operation can be performed on the content.        
00168         """        
00169 
00170     def checkin( content, checkin_messsage ):
00171         """
00172         check the working copy in, this will merge the working copy with the baseline
00173        
00174         """
00175 
00176     def checkout( container, content ):
00177         """
00178         """
00179 
00180     def cancelCheckout( content ):
00181         """
00182         """
00183 
00184 
00185 class IObjectCopier( Interface ):
00186     """ copies and merges the object state
00187     """
00188 
00189     def copyTo( container ):
00190         """ copy the context to the given container, must also create an AT relation
00191         using the WorkingCopyRelation.relation name between the source and the copy.
00192         returns the copy.
00193         """
00194         
00195     def merge( ):
00196         """ merge/replace the source with the copy, context is the copy.
00197         """
00198 
00199 class IObjectArchiver( Interface ):
00200     """ iterate needs minimal versioning support
00201     """
00202 
00203     def save( checkin_message ):
00204         """ save a new version of the object
00205         """
00206 
00207     def isVersioned( self ):
00208         """ is this content already versioned
00209         """
00210         
00211     def isVersionable( self ):
00212         """ is versionable check.
00213         """
00214 
00215     def isModified( self ):
00216         """ is the resource current state, different than its last saved state.
00217         """
00218 
00219 class ICheckinCheckoutPolicy( Interface ):
00220     """
00221     Checkin / Checkout Policy
00222     """
00223 
00224     def checkin( checkin_message ):
00225         """
00226         checkin the context, if the target has been deleted then raises a checkin exception.
00227         
00228 #       if the object version has changed since the checkout begin (due to another checkin)
00229 #       raises a conflict error.
00230 #        
00231         """
00232 
00233     def checkout( container ):
00234         """
00235         checkout the content object into the container, iff another object with
00236         the same id exists the id is amended, the working copy object is returned.
00237 
00238         the content object is locked during checkout.
00239 
00240         raises a CheckoutError if the object is already checked out.
00241         """
00242 
00243     def cancelCheckout( ):
00244         """
00245         coxtent is a checkout (working copy), this method will go ahead and delete
00246         the working copy.
00247         """
00248 
00249     def getWorkingCopies( ):
00250         """
00251         """
00252 
00253 ##     def merge( content ):
00254 ##         """
00255 ##         if there are known conflicts between the checkout and the checkedin version,
00256 ##         using the merge method signals that conflicts have been resolved in the working
00257 ##         copy.
00258 ##         """
00259 
00260 
00261 #################################
00262 
00263 class ICheckinCheckoutReference( Interface ):
00264     # a reference processor
00265 
00266     def checkout( baseline, wc, references, storage ):
00267         """
00268         handle processing of the given references from the baseline
00269         into the working copy, storage is an annotation for bookkeeping
00270         information.
00271         """
00272 
00273     def checkoutBackReferences( baseline, wc, references, storage ):
00274         """
00275         """
00276 
00277     def checkin( baseline, wc, references, storage ):
00278         """
00279         """
00280 
00281     def checkinBackReferences( baseline, wc, references, storage ):
00282         """
00283         """