[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/Views/Browser - Adder.py:1.2 Contents.py:1.2 __init__.py:1.2 add.pt:1.2 add_confirmed.pt:1.2 main.pt:1.2 remove_confirmed.pt:1.2
Jim Fulton
jim@zope.com
Mon, 10 Jun 2002 19:28:27 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv17445/lib/python/Zope/App/OFS/Container/Views/Browser
Added Files:
Adder.py Contents.py __init__.py add.pt add_confirmed.pt
main.pt remove_confirmed.pt
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.
=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Adder.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Define adder component for folders.
+
+$Id$
+"""
+
+from Zope.Publisher.Browser.BrowserView import BrowserView
+from Zope.App.PageTemplate import ViewPageTemplateFile
+from Zope.ComponentArchitecture import createObject
+from Zope.App.OFS.Services.AddableService import getAddableContent
+from Zope.App.OFS.Container.Exceptions import DuplicateIDError
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
+
+class ContainerAdder(BrowserView):
+
+ def _listAddables( self ):
+ """
+ Derived classes override this to change the registry
+ in which factories are looked up.
+ """
+ return getAddableContent(self.context)
+
+ def listAddableInfo( self ):
+ """
+ Return a sequence of mappings for the addables for our
+ folder.
+ """
+ return self._listAddables()
+
+ def action( self, id, type_name, REQUEST=None):
+ """
+ Instantiate an object and put it in our folder.
+ """
+ context = self.context
+
+ if id in context.keys():
+ raise DuplicateIDError, "ID '%s' already in use." % id
+
+ # Create the new object
+ new_object = createObject(context, type_name)
+
+ # Remove thye security proxy and context wrappers, if any.
+ # It's a good thing this is trusted code. :)
+ new_object = removeAllProxies(new_object)
+
+ context.setObject(id, new_object)
+
+ if REQUEST is not None:
+ # for unit tests
+ REQUEST.getResponse().redirect(REQUEST.URL[-1])
+
+ return self.confirmed( type_name=type_name, id=id )
+
+ index = ViewPageTemplateFile('add.pt')
+ confirmed = ViewPageTemplateFile('add_confirmed.pt')
=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Contents.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+Revision information: $Id$
+"""
+
+
+import os
+
+from Zope.Publisher.Browser.BrowserView import BrowserView
+from Zope.App.PageTemplate import ViewPageTemplateFile
+from Zope.App.OFS.Container.IContainer import IContainer
+
+class Contents(BrowserView):
+
+ __used_for__ = IContainer
+
+ def _extractContentInfo( self, item ):
+ info = {}
+ info['id'] = item[0]
+ info['object'] = item[1]
+
+ # XXX: We will fake this stuff out for now
+ info[ 'title' ] = info[ 'url' ] = item[0]
+ info['icon'] = None
+
+ return info
+
+
+ def removeObjects(self, ids, REQUEST=None):
+ """ """
+ for id in ids:
+ self.remove(id)
+
+ # XXX: This is horribly broken, but I can't do better until
+ # we have a way to compute absolute URLs.
+ if REQUEST is not None:
+ # for unit tests
+ REQUEST.getResponse().redirect(REQUEST.URL['-1'])
+ return self.confirmRemoved()
+
+
+ def remove( self, name, silent=0 ):
+ """
+ Remove the object stored under 'name', or raise a KeyError
+ if no such object (pass non-zero 'silent' to suppress the
+ exception).
+ """
+ try:
+ del self.context[name]
+ except KeyError:
+ if not silent:
+ raise
+ return self.confirmRemoved( name=name )
+
+ def listContentInfo(self):
+ return map(self._extractContentInfo, self.context.items())
+
+ index = ViewPageTemplateFile('main.pt')
+ confirmRemoved = ViewPageTemplateFile('remove_confirmed.pt')
+
=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/__init__.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/add.pt 1.1 => 1.2 ===
+<head>
+<style metal:fill-slot="headers" type="text/css">
+.TypeListing {
+ width: 100%;
+}
+
+.Selector {
+ width: 10px;
+}
+
+.TypeIcon {
+ width: 20px;
+}
+
+.TypeName {
+ text-align: left;
+}
+
+.TypeDescription {
+ text-align: left;
+ font-style: italic;
+}
+</style>
+</head>
+<body>
+
+<div metal:fill-slot="body">
+
+<form action="@@add.html" method="POST">
+<table class="TypeListing">
+
+ <caption>Add Content To Folder</caption>
+
+ <tr>
+ <td class="Selector"><br /></td>
+ <th class="TypeName">Title</th>
+ </tr>
+
+ <!--
+ ** listAddableInfo returns a sequence of mappings, containing:
+ ** 'id' : the ID of the addable type
+ ** 'title' : the title 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)
+ -->
+ <tbody tal:repeat="info view/listAddableInfo">
+
+ <tr>
+
+ <td class="Selector">
+ <input type="radio" name="type_name"
+ tal:attributes="value info/id; id info/id" />
+ </td>
+
+ <td class="TypeName">
+ <label tal:attributes="for info/id">
+ <img alt="Folder" src="../../ZMI/www/folder_icon.gif"
+ tal:condition="info/icon"
+ tal:attributes="src info/icon" />
+ <span tal:replace="info/title">Folder</span>
+ </label>
+ </td>
+
+ </tr>
+
+ <tr>
+ <td class="Selector"><br /></td>
+ <td class="TypeDescription" tal:content="info/description">
+ Folders are generic containers for content, including other
+ folders.
+ </td>
+ </tr>
+
+ </tbody>
+
+ <tbody tal:condition="nothing">
+
+ <tr>
+
+ <td class="Selector">
+ <input type="radio" name="type_name" value="" />
+
+ </td>
+
+ <td class="TypeName">
+ <img alt="Folder" src="../../ZMI/www/document_icon.gif" />
+ Document
+ </td>
+
+ </tr>
+
+ <tr>
+ <td class="Selector"><br /></td>
+ <td class="TypeDescription">
+ Documents are simple textual content.
+ </td>
+ </tr>
+
+ </tbody>
+
+ <tr>
+ <td><br/></td>
+ <td><input type="text" name="id" />
+ <input type="submit" value=" Add " />
+ </td>
+ </tr>
+
+</table>
+</form>
+</div>
+</body>
+</html>
=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/add_confirmed.pt 1.1 => 1.2 ===
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+ metal:use-macro="presentation/standard_macros/html">
+ -->
+<body>
+
+<p> Object added successfully. </p>
+
+</body>
+</html>
=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/main.pt 1.1 => 1.2 ===
+<head>
+<style metal:fill-slot="headers" type="text/css">
+<!--
+.ContentListing {
+ width: 100%;
+}
+
+.ContentIcon {
+ width: 20px;
+}
+
+.ContentTitle {
+ text-align: left;
+}
+-->
+</style>
+</head>
+<body>
+<div metal:fill-slot="body">
+
+<form action="@@index.html" method="get">
+ <table class="ContentListing">
+
+ <caption>Folder Contents <a href="@@addForm.html"> Add... </a> </caption>
+
+ <tbody>
+
+ <tr>
+ <td class="ContentIcon"><br /> </td>
+ <th class="ContentTitle">Title</th>
+ </tr>
+
+ <!--
+ ** listContentInfo returns a sequence of mappings, containing:
+ ** 'id' : the ID of the contained within the container
+ ** 'url' : the absolute URL of the contained object
+ ** 'title' : the title of the contained object
+ ** 'icon' : the absolute URL of the icon, for the contained object
+ (may be None)
+ -->
+ <tr tal:repeat="info view/listContentInfo">
+
+ <td class="ContentSelect">
+ <input type="checkbox" name="ids:list" value="id"
+ tal:attributes="value info/id" />
+ </td>
+
+ <td class="ContentIcon">
+ <img alt="Folder" src="../../ZMI/www/folder_icon.gif"
+ tal:condition="info/url"
+ tal:attributes="src info/url" />
+ </td>
+
+ <td class="ContentTitle">
+ <a href="subfolder_id"
+ tal:attributes="href string:${info/url}"
+ tal:content="info/title"
+ >Folder Title or ID here</a>
+ </td>
+
+ </tr>
+
+ <tr tal:condition="nothing">
+
+ <td class="ContentIcon">
+ <img alt="Document" src="../../ZMI/www/document_icon.gif" />
+ </td>
+
+ <td class="ContentTitle">
+ <a href="document_id">Document Title or ID here</a>
+ </td>
+
+ </tr>
+ </tbody>
+
+ </table>
+ <br />
+
+ <input type="submit" name="removeObjects:method" value="Delete"
+ i18n:attributes="value string:menu_delete_button">
+</form>
+
+</div>
+</body>
+</html>
+
+
+
+
=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/remove_confirmed.pt 1.1 => 1.2 ===
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+ metal:use-macro="presentation/standard_macros/html">
+ -->
+<body>
+
+<p> Object(s) removed successfully. </p>
+
+</body>
+</html>