[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/Views/Browser - Adding.py:1.1.2.1 IAdding.py:1.1.2.1
Gary Poster
garyposter@earthlink.net
Thu, 20 Jun 2002 11:08:17 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv1954
Added Files:
Tag: gary-zope3_add_menu-branch
Adding.py IAdding.py
Log Message:
the start of http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/AddMenuProposalAndEndOfZmiNamespace et al
=== Added File Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Adding.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.
#
##############################################################################
"""
$Id: Adding.py,v 1.1.2.1 2002/06/20 15:08:17 poster Exp $
"""
from Zope.App.OFS.Container.Views.Browser.IAdding import IAdding
from Zope.App.OFS.Container.Exceptions import DuplicateIDError
from Zope.Proxy.ProxyIntrospection import removeAllProxies
from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.ComponentArchitecture import createObject, queryView, getView
from Zope.App.OFS.Services.AddableService import getAddableContent
from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
from Zope.Publisher.XMLRPC.IXMLRPCPublisher import IXMLRPCPublisher
from Zope.Publisher.Exceptions import NotFound
from Zope.App.OFS.Container.Views.Browser.IAdder import IAdder
from Zope.ComponentArchitecture import queryView
from Zope.ComponentArchitecture import getDefaultViewName
class Adding(BrowserView):
__implements__ = IAdding, IBrowserPublisher, IXMLRPCPublisher
############################################################
# Implementation methods for interface
# IAdder.py
def add(self, content):
'See Zope.App.OFS.Container.Views.Browser.IAdder.IAdder'
context = self.context
name=self.contentName
if name in context.keys():
raise DuplicateIDError, "name '%s' already in use." % name
# Remove the security proxy and context wrappers, if any.
# It's a good thing this is trusted code. :)
content = removeAllProxies(content)
context.setObject(name, content)
# See Zope.App.OFS.Container.Views.Browser.IAdder.IAdder
contentName=None # usually set by Adder traverser
def nextURL(self):
'See Zope.App.OFS.Container.Views.Browser.IAdder.IAdder'
return str(getView(self.context, "absolute_url", self.request))
######################################
# from: Zope.ComponentArchitecture.IPresentation.IPresentation
# See Zope.ComponentArchitecture.IPresentation.IPresentation
request = None # set in BrowserView.__init__
######################################
# from: Zope.ComponentArchitecture.IContextDependent.IContextDependent
# See Zope.ComponentArchitecture.IContextDependent.IContextDependent
context = None # set in BrowserView.__init__
######################################
# from: Zope.Publisher.Browser.IBrowserPublisher.IBrowserPublisher
def publishTraverse(self, request, name):
c = self.context
nameA=name.split("=",1)
if len(nameA) == 2:
# this is a standard creation view
name, contentName=nameA
if contentName: c.contentName = contentName
view = queryView(c, name, request)
if view is not None:
return view
raise NotFound(c, name, request)
def browserDefault(self, request):
c = self.context
view_name = getDefaultViewName(c, request)
view_uri = "@@%s" % view_name
return c, (view_uri,)
#
############################################################
=== Added File Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/IAdding.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.
#
##############################################################################
"""
$Id: IAdding.py,v 1.1.2.1 2002/06/20 15:08:17 poster Exp $
"""
from Interface import Property
from Zope.ComponentArchitecture.IView import IView
class IAdding(IView):
def add(content):
"""Add the content object to a container, using the name in
contentName. If contentName is already used in container,
raises Zope.App.OFS.Container.Exceptions.DuplicateIDError"""
contentName=Property(
"""the content name, as usually set by the Adder traverser.
If the content name hasn't been defined yet, returns None.
Some creation views might use this to optionally display the
name on forms.
"""
)
def nextURL():
"""Return the URL that the creation view should redirect to
This is called by the creation view after calling add.
It is the adder's responsibility, not the creation view's to
decide what page to display after content is added.
"""
def listAddableInfo():
"""Return a sequence of mappings for the addables for our
folder.
"""