Back to index

plone3  3.1.7
checkUpToDate.py
Go to the documentation of this file.
00001 ## Script (Python) "checkUpToDate"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=history
00008 ##title=Check if Up To Date
00009 ##
00010 from Products.CMFCore.utils import getToolByName
00011 repo = getToolByName(context, "portal_repository")
00012 
00013 version_id = getattr(context, "version_id", None)
00014 if version_id is None:
00015     isModified = True
00016     reverted_vid = None
00017 else:
00018     isModified = not repo.isUpToDate(context, version_id)
00019     historyLength = len(history)
00020     reverted_vid = version_id
00021     if historyLength == version_id+1:
00022         isReverted = False
00023     else:
00024         isReverted = True
00025     if isModified:
00026         version_id = historyLength
00027 
00028 return {
00029     "isModified": isModified, 
00030     "version_id": version_id,
00031     "isReverted": isReverted,
00032     "reverted_vid": reverted_vid,
00033 }