Back to index

plone3  3.1.7
diff.py
Go to the documentation of this file.
00001 """
00002 $Id: diff.py 1807 2007-02-06 06:52:46Z hazmat $
00003 """
00004 
00005 from Products.CMFCore.utils import getToolByName
00006 from Products.Five.browser import BrowserView
00007 
00008 from plone.app.iterate.interfaces import IWorkingCopy, IBaseline
00009 from plone.app.iterate.relation import WorkingCopyRelation
00010 
00011 class DiffView( BrowserView ):
00012 
00013     def __init__( self, context, request ):
00014         self.context = context
00015         self.request = request
00016         if IBaseline.providedBy( self.context ):
00017             self.baseline = context
00018             self.working_copy = context.getBackReferences( WorkingCopyRelation.relationship )[0]
00019         elif IWorkingCopy.providedBy( self.context ):
00020             self.working_copy = context
00021             self.baseline = context.getReferences( WorkingCopyRelation.relationship )[0]
00022         else:
00023             raise AttributeError("Invalid Context")
00024 
00025     def diffs( self ):
00026         diff = getToolByName(self.context, 'portal_diff')
00027         return diff.createChangeSet( self.baseline,
00028                                      self.working_copy,
00029                                      id1="Baseline",
00030                                      id2="Working Copy" )
00031     
00032         
00033     
00034 
00035