[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZMI/Views/Browser - GenericCreatorView.py:1.1.2.1 __init__.py:1.1.2.1 browser.zcml:1.1.2.1
Gary Poster
garyposter@earthlink.net
Mon, 1 Apr 2002 14:24:33 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZMI/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv28749/Views/Browser
Added Files:
Tag: gary-pre_create_views-branch
GenericCreatorView.py __init__.py browser.zcml
Log Message:
made standard Views directory structure and modified files to use it
=== Added File Zope3/lib/python/Zope/App/ZMI/Views/Browser/GenericCreatorView.py ===
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.PageTemplate import PageTemplateFile
from provideClass import GenericCreatorMarkerInterface
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 GenericCreatorMarkerInterface
__used_for__=GenericCreatorMarkerInterface
# 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/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.provideClass.GenericCreatorMarkerInterface"
factory=".GenericCreatorView." />
<security:protectClass name=".GenericCreatorView."
permission_id="Zope.View"
methods="index, action" />
</zopeConfigure>