Back to index

plone3  3.1.7
archiver.py
Go to the documentation of this file.
00001 ##################################################################
00002 #
00003 # (C) Copyright 2006-2007 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: archiver.py 1824 2007-02-08 17:59:41Z hazmat $
00024 """
00025 
00026 from zope.interface import implements
00027 from zope.component import adapts
00028 
00029 from Products.CMFCore.utils import getToolByName
00030 
00031 import interfaces
00032 
00033 class ContentArchiver( object ):
00034 
00035     implements( interfaces.IObjectArchiver )
00036     adapts( interfaces.IIterateAware )
00037 
00038     def __init__( self, context ):
00039         self.context = context
00040         self.repository = getToolByName(context, 'portal_repository')
00041 
00042     def save( self, checkin_message ):
00043         self.repository.save( self.context, checkin_message )
00044 
00045     def isVersionable( self ):
00046         if not self.repository.isVersionable( self.context ):
00047             return False
00048         return True
00049 
00050     def isVersioned( self ):
00051         archivist = getToolByName(self.context, 'portal_archivist')
00052         version_count = len( archivist.queryHistory( self.context ) )
00053         return bool( version_count )
00054 
00055     def isModified( self ):
00056         try:
00057             return not self.repository.isUpToDate( self.context )
00058         except:
00059             return False