[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Folder - FolderAdder.py:1.1.2.4 FolderContents.py:1.1.2.2 add.pt:1.1.2.3 folder.zcml:1.1.2.4 main.pt:1.1.2.3
Paul Everitt
paul@zope.com
Thu, 28 Feb 2002 18:26:58 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Folder
In directory cvs.zope.org:/tmp/cvs-serv5207
Modified Files:
Tag: Zope-3x-branch
FolderAdder.py FolderContents.py add.pt folder.zcml main.pt
Log Message:
Changed folder attr to use addable instances in the page template.
Added some missing security assertions.
Added links and method in folder contents to create or navigate to
a service manager.
=== Zope3/lib/python/Zope/App/OFS/Folder/FolderAdder.py 1.1.2.3 => 1.1.2.4 ===
pass
-
class FolderAdder( AttributePublisher ):
__implements__ = AttributePublisher.__implements__
@@ -31,17 +30,6 @@
def __init__( self, folder ):
self._folder = folder
- def _extractAdderInfo( self, addable ):
- info = {}
- info['id'] = addable.id
- info[ 'title' ] = addable.title
- info[ 'desc' ] = addable.description
-
- # XXX: We will fake this stuff out for now
- info['icon'] = None
-
- return info
-
def _listAddables( self ):
"""
@@ -55,7 +43,7 @@
Return a sequence of mappings for the addables for our
folder.
"""
- return map( self._extractAdderInfo, self._listAddables() )
+ return self._listAddables()
def action( self, id, type_name, REQUEST=None):
"""
=== Zope3/lib/python/Zope/App/OFS/Folder/FolderContents.py 1.1.2.1 => 1.1.2.2 ===
from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
+from Zope.App.Service.ServiceManager import ServiceManager
class FolderContents( AttributePublisher ):
@@ -64,6 +65,17 @@
def listContentInfo( self ):
return map( self._extractContentInfo, self._folder.objectItems() )
+
+ def addServiceManager(self, REQUEST=None):
+ """Create a service manager then add it to the folder."""
+
+ sm = ServiceManager()
+ if self.getContext().hasServiceManager():
+ raise 'HasServiceManager', (
+ 'This folder already contains a service manager')
+ self.getContext().setServiceManager(sm)
+ if REQUEST is not None:
+ return self.index(REQUEST)
#
# Make it possible for 'index' to find the folder.
=== Zope3/lib/python/Zope/App/OFS/Folder/add.pt 1.1.2.2 => 1.1.2.3 ===
** 'id' : the ID of the addable type
** 'title' : the title of the addable type
- ** 'desc' : the description of the addable type
+ ** 'description' : the description of the addable type
** 'icon' : the absolute URL of the icon, for the addable type
(may be None)
-->
@@ -67,7 +67,7 @@
<tr>
<td class="Selector"><br /></td>
- <td class="TypeDescription" tal:content="info/desc">
+ <td class="TypeDescription" tal:content="info/description">
Folders are generic containers for content, including other
folders.
</td>
=== Zope3/lib/python/Zope/App/OFS/Folder/folder.zcml 1.1.2.3 => 1.1.2.4 ===
<security:protectClass name="Zope.App.OFS.Folder.FolderAdder."
- permission_id="Zope.ManageContent" methods="index, confirmed, action" />
+ permission_id="Zope.ManageContent"
+ methods="index, confirmed, action, listAddableInfo" />
<security:protectClass name="Zope.App.OFS.Folder."
- permission_id="Zope.View" />
+ permission_id="Zope.View">
+ <security:instances permission_id="Zope.View" />
+ <security:protect interface="Zope.ComponentArchitecture.IServiceManagerContainer."
+ permission_id="Zope.ManageServices" />
+</security:protectClass>
<security:protectClass name="Zope.App.OFS.Folder.FolderContents."
permission_id="Zope.ManageContent"
- methods="index, listContentInfo, remove, removeObjects, confirmRemoved"/>
+ methods="index, listContentInfo, remove, removeObjects, confirmRemoved, addServiceManager"/>
=== Zope3/lib/python/Zope/App/OFS/Folder/main.pt 1.1.2.2 => 1.1.2.3 ===
<table class="ContentListing">
- <caption>Folder Contents <a href="adder;view"> Add... </a> </caption>
+ <caption>Folder Contents <a href="../adder;view"> Add... </a> </caption>
<tbody>
@@ -81,6 +81,9 @@
i18n:attributes="value string:menu_delete_button">
</form>
+<p><a href="../Services;etc/" tal:condition="here/hasServiceManager">Services</a>
+<a href="addServiceManager" tal:condition="not: here/hasServiceManager">Allow Services</a>
+</p>
</div>
</body>
</html>