[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services/module - __init__.py:1.2 add_module.pt:1.2 configure.zcml:1.2 edit_module.pt:1.2

Jim Fulton jim@zope.com
Mon, 30 Jun 2003 12:23:00 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser/services/module
In directory cvs.zope.org:/tmp/cvs-serv18092/src/zope/app/browser/services/module

Added Files:
	__init__.py add_module.pt configure.zcml edit_module.pt 
Log Message:
Moved the module view code into a separate package.

Simplified views to not include input of module name.

(We need to *add* display of module name.)


=== Zope3/src/zope/app/browser/services/module/__init__.py 1.1 => 1.2 ===
--- /dev/null	Mon Jun 30 12:23:00 2003
+++ Zope3/src/zope/app/browser/services/module/__init__.py	Mon Jun 30 12:22:59 2003
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# Copyright (c) 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.
+#
+##############################################################################
+"""Handle form to create module
+
+$Id$
+"""
+
+from zope.app.interfaces.dublincore import IZopeDublinCore
+from zope.app.services.module import Manager
+from zope.component import getAdapter
+from zope.publisher.browser import BrowserView
+
+from zope.app.i18n import ZopeMessageIDFactory as _
+
+
+class AddModule(BrowserView):
+
+    def action(self, source):
+        name = self.context.contentName
+        if not name:
+            raise UserError(_(u"module name must be provided"))
+        mgr = Manager(name, source)
+        mgr = self.context.add(mgr)  # local registration
+        mgr.execute()
+        self.request.response.redirect(self.context.nextURL())
+
+class EditModule(BrowserView):
+
+    def update(self):
+        if "source" in self.request:
+            self.context.source = self.request["source"]
+            self.context.execute()
+            return _(u"The source was updated.")
+        else:
+            return u""


=== Zope3/src/zope/app/browser/services/module/add_module.pt 1.1 => 1.2 ===
--- /dev/null	Mon Jun 30 12:23:00 2003
+++ Zope3/src/zope/app/browser/services/module/add_module.pt	Mon Jun 30 12:22:59 2003
@@ -0,0 +1,13 @@
+<html metal:use-macro="views/standard_macros/page">
+<head><title>Add a module</title></head>
+<body>
+<div metal:fill-slot="body">
+
+<p>Enter the module source code.</p>
+
+<form action="action.html">
+  <textarea name="source:text" cols="65" rows="25"></textarea>
+  <input type="submit" value="Add module" />
+</form>
+
+</div></body></html>


=== Zope3/src/zope/app/browser/services/module/configure.zcml 1.1 => 1.2 ===
--- /dev/null	Mon Jun 30 12:23:00 2003
+++ Zope3/src/zope/app/browser/services/module/configure.zcml	Mon Jun 30 12:22:59 2003
@@ -0,0 +1,30 @@
+<zopeConfigure xmlns='http://namespaces.zope.org/browser'>
+
+<!-- Persistent Modules -->
+
+  <page 
+      name="edit.html" 
+      for="zope.app.interfaces.services.module.IModuleManager"
+      menu="zmi_views" title="Edit"
+      class="zope.app.browser.services.module.EditModule"
+      template="edit_module.pt" 
+      permission="zope.ManageServices"
+      />
+
+  <view for="zope.app.interfaces.container.IAdding"
+        name="Module"
+        class="zope.app.browser.services.module.AddModule"
+        permission="zope.ManageServices"
+        >
+      <page name="index.html" template="add_module.pt" />
+      <page name="action.html" attribute="action" />
+  </view>
+
+  <menuItem 
+      menu="add_component" 
+      for="zope.app.interfaces.container.IAdding"
+      action="Module"  
+      title="Module" 
+      />
+
+</zopeConfigure>


=== Zope3/src/zope/app/browser/services/module/edit_module.pt 1.1 => 1.2 ===
--- /dev/null	Mon Jun 30 12:23:00 2003
+++ Zope3/src/zope/app/browser/services/module/edit_module.pt	Mon Jun 30 12:22:59 2003
@@ -0,0 +1,16 @@
+<html metal:use-macro="views/standard_macros/page">
+<head><title>Add a module</title></head>
+<body>
+<div metal:fill-slot="body">
+
+<p>Enter the absolute module name and source code.</p>
+
+<form action="edit.html">
+<span tal:replace="view/update"></span>
+<textarea name="source:text" cols="65" rows="25"
+          tal:content="context/source"
+></textarea>
+<input type="submit" value="Edit"/>
+</form>
+
+</div></body></html>