[CMF-checkins] CVS: CMF/CMFStaging - LockTool.py:1.3 StagingTool.py:1.5 VersionsTool.py:1.4 __init__.py:1.2
Shane Hathaway
shane@cvs.zope.org
Tue, 14 May 2002 13:55:24 -0400
Update of /cvs-repository/CMF/CMFStaging
In directory cvs.zope.org:/tmp/cvs-serv20216
Modified Files:
LockTool.py StagingTool.py VersionsTool.py __init__.py
Log Message:
Added a "staging" skin layer and a management interface for the three tools.
=== CMF/CMFStaging/LockTool.py 1.2 => 1.3 ===
"""
-from Globals import InitializeClass
-from OFS.SimpleItem import SimpleItem
+import os
+
+from Globals import InitializeClass, DTMLFile
from AccessControl import ClassSecurityInfo, getSecurityManager
-from Products.CMFCore.utils import UniqueObject, getToolByName
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.utils import UniqueObject, getToolByName, \
+ SimpleItemWithProperties
+from Products.CMFCore.CMFCorePermissions import ManagePortal
from webdav.WriteLockInterface import WriteLockInterface
from webdav.LockItem import LockItem
@@ -32,6 +34,8 @@
LockObjects = 'WebDAV Lock items'
UnlockObjects = 'WebDAV Unlock items'
+_wwwdir = os.path.join(os.path.dirname(__file__), 'www')
+
def pathOf(object):
return '/'.join(object.getPhysicalPath())
@@ -41,7 +45,7 @@
pass
-class LockTool(UniqueObject, SimpleItem):
+class LockTool(UniqueObject, SimpleItemWithProperties):
__doc__ = __doc__ # copy from module
id = 'portal_lock'
meta_type = 'Portal Lock Tool'
@@ -50,21 +54,24 @@
manage_options = ( { 'label' : 'Overview', 'action' : 'manage_overview' }
,
- ) + SimpleItem.manage_options
+ ) + SimpleItemWithProperties.manage_options
# With auto_version on, locking automatically causes a version checkout
# and unlocking automatically causes a checkin. This is one form
# of autoversioning described in the DeltaV introduction.
- # Should be configurable TTW.
# http://www.webdav.org/deltav/WWW10/deltav-intro.htm
auto_version = 1
+ _properties = (
+ {'id': 'auto_version', 'type': 'boolean', 'mode': 'w',
+ 'label': 'Auto checkout and checkin using portal_versions'},
+ )
+
#
# ZMI methods
#
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'manage_overview' )
- #manage_overview = DTMLFile( 'explainDiscussionTool', _dtmldir )
+ security.declareProtected(ManagePortal, 'manage_overview' )
+ manage_overview = DTMLFile('explainLockTool', _wwwdir)
#
# 'LockTool' interface methods
=== CMF/CMFStaging/StagingTool.py 1.4 => 1.5 ===
"""
+import os
+
from Acquisition import aq_inner, aq_parent, aq_acquire
-from OFS.SimpleItem import SimpleItem
-from Globals import InitializeClass
+from Globals import InitializeClass, DTMLFile
from AccessControl import ClassSecurityInfo
+from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-from Products.CMFCore.utils import UniqueObject, getToolByName
+from Products.CMFCore.utils import UniqueObject, getToolByName, \
+ SimpleItemWithProperties
from Products.CMFCore.CMFCorePermissions import ManagePortal
# Permission name
StageObjects = 'Use version control'
+_wwwdir = os.path.join(os.path.dirname(__file__), 'www')
+
class StagingError (Exception):
"""Error while attempting to stage an object"""
-class StagingTool(UniqueObject, SimpleItem):
+class StagingTool(UniqueObject, SimpleItemWithProperties):
__doc__ = __doc__ # copy from module
id = 'portal_staging'
meta_type = 'Portal Staging Tool'
security = ClassSecurityInfo()
- manage_options = ( { 'label' : 'Overview', 'action' : 'manage_overview' }
- ,
- ) + SimpleItem.manage_options
+ manage_options = (
+ {'label': 'Overview', 'action': 'manage_overview'},
+ {'label': 'Stages', 'action': 'manage_stagesForm'},
+ ) + SimpleItemWithProperties.manage_options
- # With auto_unlock_checkin turned on, updateStages() uses the
+ # With auto_checkin turned on, updateStages() uses the
# lock tool and the versions tool to unlock and check in the object.
auto_checkin = 1
repository_name = 'VersionRepository'
+ _properties = (
+ {'id': 'repository_name', 'type': 'string', 'mode': 'w',
+ 'label': 'ID of the version repository'},
+ {'id': 'auto_checkin', 'type': 'boolean', 'mode': 'w',
+ 'label': 'Unlock and checkin before staging'},
+ )
+
# _stages maps stage names to relative paths.
- # This should be configurable TTW.
_stages = {
'dev': 'Stages/Development',
'review': 'Stages/Review',
@@ -60,7 +72,7 @@
}
security.declareProtected(ManagePortal, 'manage_overview' )
- #manage_overview = DTMLFile( 'explainStagingTool', _dtmldir )
+ manage_overview = DTMLFile('explainStagingTool', _wwwdir)
def _getVersionRepository(self):
repo = aq_acquire(self, self.repository_name, containment=1)
@@ -99,7 +111,10 @@
res = {}
for stage_name, path in self._stages.items():
stage = stages[stage_name]
- object = stage.restrictedTraverse(rel_path, None)
+ if stage is not None:
+ object = stage.restrictedTraverse(rel_path, None)
+ else:
+ object = None
res[stage_name] = object
return res
@@ -238,6 +253,31 @@
return ob.absolute_url(relative)
else:
return None
+
+
+ security.declareProtected(
+ ManagePortal, 'manage_stagesForm' 'manage_editStages', 'getStagePaths')
+
+ manage_stagesForm = PageTemplateFile('stagesForm', _wwwdir)
+
+ def getStageItems(self):
+ lst = self._stages.items()
+ lst.sort()
+ return lst
+
+ def manage_editStages(self, stages=(), RESPONSE=None):
+ """Edits the stages."""
+ ss = {}
+ for stage in stages:
+ name = str(stage.name)
+ path = str(stage.path)
+ if name and path:
+ ss[name] = path
+ self._stages = ss
+ if RESPONSE is not None:
+ RESPONSE.redirect(
+ '%s/manage_stagesForm?manage_tabs_message=Stages+changed.'
+ % self.absolute_url())
InitializeClass(StagingTool)
=== CMF/CMFStaging/VersionsTool.py 1.3 => 1.4 ===
"""
+import os
+
from Acquisition import aq_acquire
-from OFS.SimpleItem import SimpleItem
-from Globals import InitializeClass
+from Globals import InitializeClass, DTMLFile
from AccessControl import ClassSecurityInfo
-from Products.CMFCore.utils import UniqueObject
+from Products.CMFCore.utils import UniqueObject, SimpleItemWithProperties
from Products.CMFCore.CMFCorePermissions import ManagePortal
# Permission name
UseVersionControl = 'Use version control'
+_wwwdir = os.path.join(os.path.dirname(__file__), 'www')
+
-class VersionsTool(UniqueObject, SimpleItem):
+class VersionsTool(UniqueObject, SimpleItemWithProperties):
__doc__ = __doc__ # copy from module
id = 'portal_versions'
meta_type = 'Portal Versions tool'
security = ClassSecurityInfo()
- manage_options = ( { 'label' : 'Overview', 'action' : 'manage_overview' }
- ,
- ) + SimpleItem.manage_options
+ manage_options = ({'label' : 'Overview', 'action' : 'manage_overview'},
+ ) + SimpleItemWithProperties.manage_options
# With auto_copy_forward turned on, the versions tool lets users
@@ -50,8 +52,15 @@
repository_name = 'VersionRepository'
+ _properties = (
+ {'id': 'repository_name', 'type': 'string', 'mode': 'w',
+ 'label': 'ID of the version repository'},
+ {'id': 'auto_copy_forward', 'type': 'boolean', 'mode': 'w',
+ 'label': 'Copy old revisions forward rather than disallow checkout'},
+ )
+
security.declareProtected(ManagePortal, 'manage_overview' )
- #manage_overview = DTMLFile( 'explainVersionsTool', _dtmldir )
+ manage_overview = DTMLFile( 'explainVersionsTool', _wwwdir )
def _getVersionRepository(self):
repo = aq_acquire(self, self.repository_name, containment=1)
=== CMF/CMFStaging/__init__.py 1.1.1.1 => 1.2 ===
import VersionsTool, StagingTool, LockTool
-#registerDirectory('skins', globals())
+registerDirectory('skins', globals())
tools = (
VersionsTool.VersionsTool,