Back to index

plone3  3.1.7
ZopeRepository.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
00004 # 
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE
00011 # 
00012 ##############################################################################
00013 
00014 __version__='$Revision: 1.5 $'[11:-2]
00015 
00016 from Globals import DTMLFile, InitializeClass
00017 from SequenceWrapper import SequenceWrapper
00018 import OFS, AccessControl
00019 import Repository
00020 
00021 
00022 class ZopeRepository(
00023     Repository.Repository,
00024     AccessControl.Role.RoleManager,
00025     OFS.SimpleItem.Item,
00026     ):
00027     """The ZopeRepository class builds on the core Repository implementation
00028        to provide the Zope management interface and other product trappings."""
00029 
00030     security = AccessControl.ClassSecurityInfo()
00031 
00032     meta_type = 'Repository'
00033 
00034     manage_options=(
00035         ( {'label': 'Contents',    'action':'manage_main',
00036            'help': ('ZopeVersionControl', 'Repository-Manage.stx')},
00037           {'label': 'Properties', 'action':'manage_properties_form',
00038            'help': ('ZopeVersionControl', 'Repository-Properties.stx')},
00039         ) +
00040         AccessControl.Role.RoleManager.manage_options +
00041         OFS.SimpleItem.Item.manage_options
00042         )
00043 
00044     security.declareProtected('View management screens', 'manage_main')
00045     manage_main = DTMLFile('dtml/RepositoryManageMain', globals())
00046     manage_main._setName('manage_main')
00047     manage = manage_main
00048 
00049     def __init__(self, id=None, title=''):
00050         Repository.Repository.__init__(self)
00051         if id is not None:
00052            self._setId( id )
00053         self.title = title
00054 
00055     security.declareProtected(
00056         'View management screens','manage_properties_form'
00057         )
00058     manage_properties_form = DTMLFile('dtml/RepositoryProperties', globals())
00059 
00060     security.declareProtected('Manage repositories', 'manage_edit')
00061     def manage_edit(self, title='', REQUEST=None):
00062         """Change object properties."""
00063         self.title = title
00064         if REQUEST is not None:
00065             message="Saved changes."
00066             return self.manage_properties_form(
00067                 self, REQUEST, manage_tabs_message=message
00068                 )
00069 
00070     def __getitem__(self, name):
00071         history = self._histories.get(name)
00072         if history is not None:
00073             return history.__of__(self)
00074         raise KeyError, name
00075 
00076     security.declarePrivate('objectIds')
00077     def objectIds(self, spec=None):
00078         return SequenceWrapper(self, self._histories.keys())
00079 
00080     security.declarePrivate('objectValues')
00081     def objectValues(self, spec=None):
00082         return SequenceWrapper(self, self._histories.values())
00083 
00084     security.declarePrivate('objectItems')
00085     def objectItems(self, spec=None):
00086         return SequenceWrapper(self, self._histories.items(), 1)
00087 
00088 InitializeClass(ZopeRepository)
00089 
00090 
00091 
00092 def addRepository(self, id, title='', REQUEST=None):
00093     """Zope object constructor function."""
00094     object = ZopeRepository(title=title)
00095     object._setId( id )
00096     self._setObject(id, object)
00097     object = self._getOb(id)
00098     if REQUEST is not None:
00099         try:    url = self.DestinationURL()
00100         except: url = REQUEST['URL1']
00101         REQUEST.RESPONSE.redirect('%s/manage_main' % url)
00102     return
00103 
00104 addRepositoryForm = DTMLFile('dtml/RepositoryAddForm', globals())
00105 
00106 
00107 constructors = (
00108   ('addRepositoryForm', addRepositoryForm),
00109   ('addRepository',     addRepository),
00110 )