Commit 5301e7f2 authored by 's avatar

- resynced Products.Five.browser.adding with zope.app.container.browser.adding

parent e774bf3a
...@@ -23,27 +23,24 @@ $Id$ ...@@ -23,27 +23,24 @@ $Id$
__docformat__ = 'restructuredtext' __docformat__ = 'restructuredtext'
from warnings import warn from zope.app.publisher.browser.menu import getMenu
from zope.browser.interfaces import IAdding
from zope.component import getMultiAdapter from zope.component import getMultiAdapter
from zope.component import getUtility from zope.component import getUtility
from zope.component import queryMultiAdapter from zope.component import queryMultiAdapter
from zope.component import queryUtility from zope.component import queryUtility
from zope.component.interfaces import IFactory from zope.component.interfaces import IFactory
from zope.container.constraints import checkFactory, checkObject from zope.container.constraints import checkFactory
from zope.container.constraints import checkObject
from zope.container.i18n import ZopeMessageFactory as _ from zope.container.i18n import ZopeMessageFactory as _
from zope.container.interfaces import IContainerNamesContainer from zope.container.interfaces import IContainerNamesContainer
from zope.container.interfaces import INameChooser from zope.container.interfaces import INameChooser
from zope.event import notify from zope.event import notify
from zope.exceptions.interfaces import UserError
from zope.interface import implements from zope.interface import implements
from zope.lifecycleevent import ObjectCreatedEvent
from zope.publisher.interfaces import IPublishTraverse from zope.publisher.interfaces import IPublishTraverse
from zope.traversing.browser.absoluteurl import absoluteURL from zope.traversing.browser.absoluteurl import absoluteURL
from zope.exceptions.interfaces import UserError
from zope.lifecycleevent import ObjectCreatedEvent
from zope.browser.interfaces import IAdding
from zope.app.publisher.browser.menu import getMenu
from zExceptions import BadRequest from zExceptions import BadRequest
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
...@@ -51,7 +48,8 @@ from OFS.SimpleItem import SimpleItem ...@@ -51,7 +48,8 @@ from OFS.SimpleItem import SimpleItem
from Products.Five import BrowserView from Products.Five import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
class BasicAdding(BrowserView):
class Adding(BrowserView):
implements(IAdding, IPublishTraverse) implements(IAdding, IPublishTraverse)
def add(self, content): def add(self, content):
...@@ -80,7 +78,7 @@ class BasicAdding(BrowserView): ...@@ -80,7 +78,7 @@ class BasicAdding(BrowserView):
# Invoke the name chooser even when we have a # Invoke the name chooser even when we have a
# name. It'll do useful things with it like converting # name. It'll do useful things with it like converting
# the incoming unicode to an ASCII string. # the incoming unicode to an ASCII string.
name = chooser.chooseName(name, container) name = chooser.chooseName(name, content)
content.id = name content.id = name
container._setObject(name, content) container._setObject(name, content)
...@@ -94,18 +92,12 @@ class BasicAdding(BrowserView): ...@@ -94,18 +92,12 @@ class BasicAdding(BrowserView):
# XXX this is definitely not right for all or even most uses # XXX this is definitely not right for all or even most uses
# of Five, but can be overridden by an AddView subclass, using # of Five, but can be overridden by an AddView subclass, using
# the class attribute of a zcml:addform directive # the class attribute of a zcml:addform directive
return str(getMultiAdapter((self.context, self.request), return absoluteURL(self.context, self.request) + '/manage_main'
name=u"absolute_url")) + '/manage_main'
# set in BrowserView.__init__ # set in BrowserView.__init__
request = None request = None
context = None context = None
def renderAddButton(self):
warn("The renderAddButton method is deprecated, use nameAllowed",
DeprecationWarning, 2)
def publishTraverse(self, request, name): def publishTraverse(self, request, name):
"""See zope.publisher.interfaces.IPublishTraverse""" """See zope.publisher.interfaces.IPublishTraverse"""
if '=' in name: if '=' in name:
...@@ -127,7 +119,7 @@ class BasicAdding(BrowserView): ...@@ -127,7 +119,7 @@ class BasicAdding(BrowserView):
factory = queryUtility(IFactory, name) factory = queryUtility(IFactory, name)
if factory is None: if factory is None:
return super(BasicAdding, self).publishTraverse(request, name) return super(Adding, self).publishTraverse(request, name)
return factory return factory
...@@ -143,11 +135,10 @@ class BasicAdding(BrowserView): ...@@ -143,11 +135,10 @@ class BasicAdding(BrowserView):
else: else:
view_name = type_name view_name = type_name
if (queryMultiAdapter((self, self.request), name=view_name) if queryMultiAdapter((self, self.request),
is not None): name=view_name) is not None:
url = "%s/%s=%s" % ( url = "%s/%s=%s" % (
getMultiAdapter((self, self.request), name=u"absolute_url"), absoluteURL(self, self.request), type_name, id)
type_name, id)
self.request.response.redirect(url) self.request.response.redirect(url)
return return
...@@ -162,16 +153,10 @@ class BasicAdding(BrowserView): ...@@ -162,16 +153,10 @@ class BasicAdding(BrowserView):
self.add(content) self.add(content)
self.request.response.redirect(self.nextURL()) self.request.response.redirect(self.nextURL())
def namesAccepted(self):
return not IContainerNamesContainer.providedBy(self.context)
def nameAllowed(self): def nameAllowed(self):
"""Return whether names can be input by the user.""" """Return whether names can be input by the user."""
return not IContainerNamesContainer.providedBy(self.context) return not IContainerNamesContainer.providedBy(self.context)
class Adding(BasicAdding):
menu_id = None menu_id = None
index = ViewPageTemplateFile("adding.pt") index = ViewPageTemplateFile("adding.pt")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment