[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZMI/Views/Browser - GenericCreatorView.py:1.1.4.1 __init__.py:1.1.4.1 add.pt:1.1.4.1 add_confirmed.pt:1.1.4.1 browser.zcml:1.1.4.1
Gary Poster
garyposter@earthlink.net
Wed, 3 Apr 2002 22:53:23 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZMI/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv7752/ZMI/Views/Browser
Added Files:
Tag: Zope-3x-branch
GenericCreatorView.py __init__.py add.pt add_confirmed.pt
browser.zcml
Log Message:
checking in gary-pre_create_view-branch, with support for create namespace. Because I merged in the Zope-3x-branch earlier and then had to run the license script again, many (most?) of the files were touched. I am checking these in incrementally, since I ran into trouble overloading the cvs server when I had to do this for my own branch. I will notate the last checkin, and then immediately check it out again to check my work.
=== Added File Zope3/lib/python/Zope/App/ZMI/Views/Browser/GenericCreatorView.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.
#
##############################################################################
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.PageTemplate import PageTemplateFile
from Zope.App.ZMI.IGenericCreatorMarker import IGenericCreatorMarker
from Zope.ContextWrapper import getcontext
from Zope.App.OFS.Container.Exceptions import DuplicateIDError
from Zope.ComponentArchitecture import createObject
class GenericCreatorView(AttributePublisher):
"""Provide an interface for editing a contact
"""
# Boiler plate
def __init__(self, context):
self._context=context
def getContext(self):
return self._context
# Assert that we can only be applied to IGenericCreatorMarker
__used_for__=IGenericCreatorMarker
# Input form
index = PageTemplateFile('add.pt', globals())
# action method
def action(self, name, REQUEST=None):
"Create an item of the class identified by the Addable (held in _context) within the container that is the parent of the Addable"
addable=self.getContext()
container=getcontext(addable)
if name in container.objectIds():
raise DuplicateIDError, "ID '%s' already in use." % name
container.setObject(name, createObject(container, addable.id()))
if REQUEST is not None:
# for unit tests
REQUEST.getResponse().redirect(REQUEST.URL[-3])
return self.confirmed( type_name=addable.id(), id=name )
confirmed = PageTemplateFile('add_confirmed.pt')
=== Added File Zope3/lib/python/Zope/App/ZMI/Views/Browser/__init__.py ===
=== Added File Zope3/lib/python/Zope/App/ZMI/Views/Browser/add.pt ===
<html><!-- metal:use-macro="views/standard_macros/page" -->
<head>
<title>add</title>
</head>
<body>
<div><!-- metal:fill-slot="body" -->
<h1>Add <span tal:replace="context/title">Item Title</span></h1>
<p tal:content="context/description">The item's description goes here</p>
<form action="action.html" method="POST">
<p>Enter the id (or file name, as seen in the URL) for this item, and click "Add".</p>
<input type="text" name="name" />
<input type="submit" value=" Add " />
</form>
</div>
</body>
</html>
=== Added File Zope3/lib/python/Zope/App/ZMI/Views/Browser/add_confirmed.pt ===
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
metal:use-macro="presentation/standard_macros/html">
-->
<body>
<p> Object added successfully. </p>
</body>
</html>
=== Added File Zope3/lib/python/Zope/App/ZMI/Views/Browser/browser.zcml ===
<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
xmlns:security='http://namespaces.zope.org/security'
xmlns:zmi='http://namespaces.zope.org/zmi'
xmlns:browser='http://namespaces.zope.org/browser'
>
<browser:defaultView name="simple_create"
for="Zope.App.ZMI.IGenericCreatorMarker."
factory=".GenericCreatorView." />
<security:protectClass name=".GenericCreatorView."
permission_id="Zope.View"
methods="index, action" />
</zopeConfigure>