Back to index

plone3  3.1.7
event.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: event.py 1811 2007-02-06 18:40:02Z hazmat $
00024 """
00025 from zope.interface import implements
00026 from zope.event import notify
00027 from zope.component.interfaces import ObjectEvent
00028 
00029 import interfaces
00030 import relation
00031 
00032 class CheckoutEvent( ObjectEvent ):
00033 
00034     implements( interfaces.ICheckoutEvent )
00035 
00036     def __init__(self, baseline, wc, relation):
00037         ObjectEvent.__init__(self, baseline )
00038         self.working_copy = wc
00039         self.relation = relation
00040         
00041 class CheckinEvent( ObjectEvent ):
00042 
00043     implements( interfaces.ICheckinEvent )
00044 
00045     def __init__(self, wc, baseline, relation, message):
00046         ObjectEvent.__init__( self, wc )
00047         self.baseline = baseline
00048         self.relation = relation
00049         self.message = message
00050 
00051 class AfterCheckinEvent( ObjectEvent ):
00052 
00053     implements( interfaces.IAfterCheckinEvent )
00054     
00055     def __init__( self, new_baseline, checkin_message ):
00056         super( AfterCheckinEvent, self).__init__( new_baseline )
00057         self.message = checkin_message
00058 
00059 class CancelCheckoutEvent( ObjectEvent ):
00060 
00061     implements( interfaces.ICancelCheckoutEvent )
00062 
00063     def __init__( self, wc, baseline):
00064         ObjectEvent.__init__(self, wc )
00065         self.baseline = baseline
00066 
00067 class WorkingCopyDeletedEvent( ObjectEvent ):
00068 
00069     implements( interfaces.IWorkingCopyDeletedEvent )
00070 
00071     def __init__( self, wc, baseline, relation ):
00072         ObjectEvent.__init__( self, wc )
00073         self.baseline = baseline
00074         self.relation = relation
00075 
00076 class BeforeCheckoutEvent( ObjectEvent ):
00077 
00078     implements( interfaces.IBeforeCheckoutEvent )
00079     
00080 
00081 def handleDeletion( reference, event ):
00082     # a filtering/enriching event rebroadcaster for working copy deletions
00083     workingCopy = reference.getSourceObject()
00084     baseline = reference.getTargetObject()
00085     notify( WorkingCopyDeletedEvent( workingCopy, baseline, reference ) )
00086