[Zope3-checkins] CVS: Products3/NewsSite - add.pt:1.1 browser.py:1.1 configure.zcml:1.4

Tres Seaver tseaver@zope.com
Wed, 26 Mar 2003 07:15:20 -0500


Update of /cvs-repository/Products3/NewsSite
In directory cvs.zope.org:/tmp/cvs-serv32719

Modified Files:
	configure.zcml 
Added Files:
	add.pt browser.py 
Log Message:


  Make NewsItems addable only from the NewsSite folder:

  - Define a new menu, 'add_news'.

  - Register NewsItem's add form into that menu.

  - Derive a custom IAdding implementation for NewsSite, which overrides
    only the menu_id.

  - Register the custom IAdding for INewsSite.


=== Added File Products3/NewsSite/add.pt ===
<html metal:use-macro="views/standard_macros/dialog">
<body>

<div metal:fill-slot="body">
<form action="action.html" method="POST">
<table class="TypeListing" cellpadding="3">

  <caption>Add Content</caption>

    <tbody tal:repeat="info view/addingInfo">

    <tr>

      <td class="Selector">
        <input type="radio" name="type_name"
               tal:attributes="value info/action; id info/action" />
      </td>

      <td class="TypeName">
        <label style="font-weight: bold;"
               tal:attributes="for info/action">
          <span tal:replace="info/title" >Folder</span>
        </label>
        <div class="TypeDescription" tal:content="info/description">
          Folders are generic containers for content, including other
          folders.
        </div>
      </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"
               tal:condition="view/namesAccepted"
	       tal:attributes="value request/id | nothing"
        />
        <input type="submit" value=" Add " />
    </td>
  </tr>

</table>
</form>
</div>
</body>
</html>



=== Added File Products3/NewsSite/browser.py ===
##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################
"""Browser views for NewsSite objects.

$Id: browser.py,v 1.1 2003/03/26 12:14:49 tseaver Exp $
"""

from zope.app.browser.container.adding import Adding

class NewsSiteAdding(Adding):
    """Custom adding view for NewsSite objects.
    """
    menu_id = "add_news"


=== Products3/NewsSite/configure.zcml 1.3 => 1.4 ===
--- Products3/NewsSite/configure.zcml:1.3	Wed Mar 26 06:54:09 2003
+++ Products3/NewsSite/configure.zcml	Wed Mar 26 07:14:49 2003
@@ -2,6 +2,9 @@
     xmlns='http://namespaces.zope.org/zope'
     xmlns:browser='http://namespaces.zope.org/browser'
 >
+
+<browser:menu id="add_news" title="News Site Items" />
+
 <include package=".NewsItem" />
 <!-- Configuration for News Site Object -->
 <content 
@@ -42,7 +45,19 @@
     description="A boring news site."
 />
 	
+<browser:view
+    for=".interfaces.INewsSite"
+    name="+" 
+    menu="zmi_actions" title="Add"
+    class=".browser.NewsSiteAdding"
+    permission="zope.ManageContent"
+    allowed_attributes="addingInfo"
+    >
+
+    <browser:page name="index.html"  template="add.pt" />
+    <browser:page name="action.html" attribute="action" />
 
+</browser:view>
 
 <!--
 <browser:addform