[Zope3-checkins] CVS: Zope3/src/zope/app/module/browser -
__init__.py:1.1 add_module.pt:1.1 browse_module.pt:1.1
configure.zcml:1.1 edit_module.pt:1.1
Stephan Richter
srichter at cosmos.phy.tufts.edu
Wed Mar 10 12:00:56 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/module/browser
In directory cvs.zope.org:/tmp/cvs-serv6102/src/zope/app/module/browser
Added Files:
__init__.py add_module.pt browse_module.pt configure.zcml
edit_module.pt
Log Message:
Moved persistent module (manager) code to zope.app.module. I did not provide
any module aliases, since noone uses this feature yet based on a recent ML
poll. If someone really needs the aliases, please let me know and I will add
them.
=== Added File Zope3/src/zope/app/module/browser/__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 2004/03/10 17:00:54 srichter Exp $
"""
from zope.app.module import Manager
from zope.app.event import publish
from zope.app.event.objectevent import ObjectCreatedEvent
from zope.publisher.browser import BrowserView
from zope.proxy import removeAllProxies
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())
publish(self.context.context, ObjectCreatedEvent(mgr))
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""
class ViewModule(BrowserView):
def getModuleName(self):
module = removeAllProxies(self.context.getModule())
remove_keys = ['__name__', '__builtins__', '_p_serial']
L = [(getattr(obj, '__name__', id),
getattr(obj, '__doc__', ''),
type(obj).__name__
)
for id, obj in module.__dict__.items()
if id not in remove_keys]
L.sort()
l_dict = [{"name": name, "doc": doc, "objtype": objtype} for name, doc, objtype in L]
for dic in l_dict:
if dic['objtype'].find('Class') != -1: dic['objtype'] = 'Class'
if dic['objtype'].find('Function') != -1: dic['objtype'] = 'Function'
return l_dict
=== Added File Zope3/src/zope/app/module/browser/add_module.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<title metal:fill-slot="title" i18n:translate="">Add a Module</title>
</head>
<body>
<div metal:fill-slot="body">
<p i18n:translate="">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"
i18n:attributes="value add-module-button"/>
</form>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/module/browser/browse_module.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<title metal:fill-slot="title" i18n:translate="">View Module Names</title>
</head>
<body>
<div metal:fill-slot="body">
<table class="listingdescription" summary="Module Listing"
cellspacing="0" >
<thead>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</thead>
<tal:repeat tal:repeat="dict view/getModuleName">
<tr tal:define="oddrow repeat/dict/odd;"
tal:attributes="class python:oddrow and 'even' or 'odd'">
<td tal:content="dict/name">An name</td>
<td tal:content="dict/objtype">Type</td>
<td tal:content="dict/doc">DocString</td>
</tr>
</tal:repeat>
</table>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/module/browser/configure.zcml ===
<zope:configure
xmlns:zope="http://namespaces.zope.org/zope"
xmlns='http://namespaces.zope.org/browser'
i18n_domain='zope'
>
<page
name="edit.html"
for="zope.app.module.interfaces.IModuleManager"
menu="zmi_views" title="Edit"
class=".EditModule"
template="edit_module.pt"
permission="zope.ManageServices"
/>
<view for="zope.app.container.interfaces.IAdding"
name="Module"
class=".AddModule"
permission="zope.ManageServices"
>
<page name="index.html" template="add_module.pt" />
<page name="action.html" attribute="action" />
</view>
<page
name="browse.html"
for="zope.app.module.interfaces.IModuleManager"
menu="zmi_views" title="Browse"
permission="zope.ManageServices"
class=".ViewModule"
template="browse_module.pt"
/>
<menuItem
menu="add_component"
for="zope.app.container.interfaces.IAdding"
action="Module"
title="Module"
/>
</zope:configure>
=== Added File Zope3/src/zope/app/module/browser/edit_module.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<title metal:fill-slot="title" i18n:translate="">Edit a Module</title>
</head>
<body>
<div metal:fill-slot="body">
<p i18n:translate="">Enter the module 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>
<br />
<input type="submit" value="Save Changes"
i18n:attributes="value edit-button"/>
</form>
</div>
</body>
</html>
More information about the Zope3-Checkins
mailing list