[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Browser - viewpackage.py:1.1.2.1 viewpackage_contents.pt:1.1.2.1 configure.zcml:1.2.12.2

Jim Fulton jim@zope.com
Thu, 12 Dec 2002 10:20:26 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Browser
In directory cvs.zope.org:/tmp/cvs-serv23093/lib/python/Zope/App/OFS/Services/ServiceManager/Browser

Modified Files:
      Tag: AdapterAndView-branch
	configure.zcml 
Added Files:
      Tag: AdapterAndView-branch
	viewpackage.py viewpackage_contents.pt 
Log Message:
Got view service and view registration working TTW (sort of).

This includes a new "View Package". You set up a view package with
default registration parameters. Then, as you add ZPT templates to the
package, they are automatically registered as views.

There are lots of rough edges that need to be smoothed out after the
sprint and before this branch merge.



=== Added File Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Browser/viewpackage.py ===
##############################################################################
#
# 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: viewpackage.py,v 1.1.2.1 2002/12/12 15:19:55 jim Exp $
"""
from Zope.App.OFS.Container.Views.Browser.Contents import Contents
from Zope.App.OFS.Services.ServiceManager.IServiceManager \
     import IServiceManager
from Zope.App.OFS.Services.zpt import ZPTTemplate


from Zope.Publisher.Browser.BrowserView import BrowserView

from Zope.App.PageTemplate import ViewPageTemplateFile
from Zope.App.OFS.Container.IContainer import IContainer
from Zope.ComponentArchitecture import queryView, getView

class ViewPackageContents(Contents):

    __used_for__ = IServiceManager

    index = ViewPageTemplateFile('viewpackage_contents.pt')

    def add(self, name):
        self.context.setObject(name, ZPTTemplate())
        self.request.response.redirect('.')


=== Added File Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Browser/viewpackage_contents.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<style metal:fill-slot="headers" type="text/css">
</style>
</head>
<body>
<div metal:fill-slot="body">

<form action="." method="get" 
      tal:define="container_contents view/listContentInfo"
      >

  <p>View Package Contents</p>

  <div metal:use-macro="view/contentsMacros/macros/contents_table" />

  <br />
    <input type="text" name="name" />
    <input type="submit" name="@@add.html:method" value="Add"
           i18nXXX:attributes="value string:menu_add_button" />
    <input type="submit" name="@@removeObjects.html:method" value="Delete"
           i18nXXX:attributes="value string:menu_delete_button" /> 
</form>

</div>
</body>
</html>


=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Browser/configure.zcml 1.2.12.1 => 1.2.12.2 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Browser/configure.zcml:1.2.12.1	Wed Dec 11 06:41:09 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/Browser/configure.zcml	Thu Dec 12 10:19:55 2002
@@ -210,4 +210,45 @@
   <menuItem menu="add_component" for="Zope.App.OFS.Container.IAdding."
      action="Module"  title="Module" />
 
+
+<!-- View Package -->
+
+  <defaultView for=".interfaces.IViewPackage." name="contents.html" />
+
+  <view
+      for=".interfaces.IViewPackage."
+      permission="Zope.ManageServices" 
+      factory=".Browser.viewpackage.ViewPackageContents.">
+
+    <page name="contents.html"
+                  attribute="index"
+                  />
+    <page name="add.html"
+                  attribute="add"
+                  />
+    <page name="removeObjects.html"
+                  attribute="removeObjects"
+                  />
+  </view>
+
+  <form:edit
+     schema=".interfaces.IViewPackageInfo."
+     name="DefaultConfiguration.html"
+     permission="Zope.ManageServices"
+     label="Default configuration parameters"
+     />
+
+  <menuItems menu="zmi_views" for=".interfaces.IViewPackage.">
+    <menuItem title="Contents"
+              action="@@contents.html"/>
+    <menuItem title="Default Configuration"
+              action="@@DefaultConfiguration.html"/>
+  </menuItems>
+
+  <menuItem menu="add_component" for="Zope.App.OFS.Container.IAdding."
+     action="Zope.App.OFS.Services.ServiceManager.viewpackage.ViewPackage" 
+     title="View Sub-Package" />
+
+
+
 </zope:zopeConfigure>