[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services/module - __init__.py:1.1.2.1 add_module.pt:1.1.2.1 configure.zcml:1.1.2.1 edit_module.pt:1.1.2.1
Jim Fulton
jim@zope.com
Mon, 30 Jun 2003 07:15:50 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/services/module
In directory cvs.zope.org:/tmp/cvs-serv6099/src/zope/app/browser/services/module
Added Files:
Tag: fdrake-local-modules-branch
__init__.py add_module.pt configure.zcml edit_module.pt
Log Message:
Checkpointing to branch. Will make detailed comments in merge.
=== Added File Zope3/src/zope/app/browser/services/module/__init__.py ===
##############################################################################
#
# 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: __init__.py,v 1.1.2.1 2003/06/30 11:15:48 jim Exp $
"""
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""
=== Added File Zope3/src/zope/app/browser/services/module/add_module.pt ===
<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>
=== Added File Zope3/src/zope/app/browser/services/module/configure.zcml ===
<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>
=== Added File Zope3/src/zope/app/browser/services/module/edit_module.pt ===
<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>