Death to __of__!

parent 22f2299a
......@@ -192,7 +192,7 @@ class Traversable:
if ns:
try:
next = namespaceLookup(
ns, nm, obj, self.REQUEST).__of__(obj)
ns, nm, obj, self.REQUEST)
if restricted and not validate(
obj, obj, name, next):
raise Unauthorized(name)
......@@ -260,7 +260,7 @@ class Traversable:
Interface, name)
if next is not None:
next = next.__of__(obj)
next = next
if restricted and not validate(obj, obj, name, next):
raise Unauthorized(name)
elif bobo_traverse is not None:
......
......@@ -209,9 +209,9 @@ class view(zope_app_view):
view = component.queryMultiAdapter((self, request), name=name,
default=None)
if view is not None:
return view.__of__(self)
return view
m = class_.publishTraverse.__get__(self).__of__(self)
m = class_.publishTraverse.__get__(self)
return m(request, name)
else:
......@@ -223,7 +223,7 @@ class view(zope_app_view):
view = component.queryMultiAdapter((self, request), name=name,
default=None)
if view is not None:
return view.__of__(self)
return view
raise NotFoundError(self, name, request)
......
......@@ -41,11 +41,6 @@ class Z2ProviderExpression(StringExpr):
if provider is None:
raise cp_interfaces.ContentProviderLookupError(name)
# Wrap the content provider's in its __parent__, whatever that
# may be (typically the view).
if getattr(provider, '__of__', None) is not None:
provider = provider.__of__(provider.__parent__)
# Insert the data gotten from the context
addTALNamespaceData(provider, econtext)
......
......@@ -18,7 +18,6 @@ $Id$
import os
import urllib
import Acquisition
from OFS.Traversable import Traversable as OFSTraversable
from zope.app.publisher.browser.resources import empty
from zope.app.publisher.fileresource import File, Image
......@@ -28,12 +27,11 @@ from zope.component import getMultiAdapter
from zope.component.interfaces import IResource
from zope.datetime import time as timeFromDateTimeString
from zope.traversing.browser.interfaces import IAbsoluteURL
from Products.Five.browser import BrowserView
_marker = []
class Resource(Acquisition.Explicit):
class Resource(object):
"""A publishable resource
"""
implements(IResource)
......@@ -63,7 +61,7 @@ class PageTemplateResource(BrowserView, Resource):
"""Rendered content"""
# ZPublisher might have called setBody with an incorrect URL
# we definitely don't want that if we are plain html
self.request.RESPONSE.setBase(None)
self.request.response.setBase(None)
pt = self.context
return pt(self.request)
......@@ -229,11 +227,7 @@ class DirectoryResource(BrowserView, Resource, OFSTraversable):
resource = factory(name, filename)(self.request)
resource.__name__ = name
resource.__parent__ = self
# XXX __of__ wrapping is usually done on traversal.
# However, we don't want to subclass Traversable (or do we?)
# The right thing should probably be a specific (and very simple)
# traverser that does __getitem__ and __of__.
return resource.__of__(self)
return resource
class DirectoryResourceFactory(ResourceFactory):
......
......@@ -221,7 +221,6 @@ so we get ('',) instead of ('eagle',):
Wrap into an acquisition so that imPermissionRole objects can be
evaluated. __roles__ is a imPermissionRole object:
>>> view = view.__of__(self.folder.testoid)
>>> view_roles = getattr(view, '__roles__', None)
>>> view_roles
('Manager',)
......
......@@ -22,23 +22,20 @@ ZopeTwoPageTemplateFile with the proper acquisition context.
$Id$
"""
import Acquisition
import zope.app.form.browser.objectwidget
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass as initializeClass
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
class ObjectWidgetView(Acquisition.Explicit,
zope.app.form.browser.objectwidget.ObjectWidgetView):
class ObjectWidgetView(zope.app.form.browser.objectwidget.ObjectWidgetView):
security = ClassSecurityInfo()
security.declareObjectPublic()
template = ZopeTwoPageTemplateFile('objectwidget.pt')
template = ViewPageTemplateFile('objectwidget.pt')
initializeClass(ObjectWidgetView)
class ObjectWidgetClass(Acquisition.Explicit,
zope.app.form.browser.objectwidget.ObjectWidget):
class ObjectWidgetClass(zope.app.form.browser.objectwidget.ObjectWidget):
def __init__(self, context, request, factory, **kw):
super(ObjectWidgetClass, self).__init__(context, request, factory, **kw)
......@@ -58,8 +55,4 @@ class ObjectWidgetClass(Acquisition.Explicit,
val = self.context.schema[name].default
self.getSubWidget(name).setRenderedValue(val)
def ObjectWidget(context, request, factory, **kw):
"""Return an ObjectWidget suitable in the Five environment, with
right acquisition context"""
return ObjectWidgetClass(context, request, factory, **kw
).__of__(context.context)
ObjectWidget = ObjectWidetClass
......@@ -41,9 +41,6 @@ class ViewletManagerBase(origManagerBase, Acquisition.Explicit):
raise zope.component.interfaces.ComponentLookupError(
'No provider with name `%s` found.' %name)
# Wrap the viewlet for security lookups
viewlet = viewlet.__of__(viewlet.context)
# If the viewlet cannot be accessed, then raise an
# unauthorized error
if not guarded_hasattr(viewlet, 'render'):
......@@ -65,8 +62,6 @@ class ViewletManagerBase(origManagerBase, Acquisition.Explicit):
# the object has a real context from which to determine owner
# security.
for name, viewlet in viewlets:
if getattr(viewlet, '__of__', None) is not None:
viewlet = viewlet.__of__(viewlet.__parent__)
if guarded_hasattr(viewlet, 'render'):
results.append((name, viewlet))
return results
......
......@@ -95,7 +95,7 @@ class DefaultPublishTraverse(object):
request.response.setStatus(200)
# We don't need to do the docstring security check
# for views, so lets skip it and return the object here.
return subobject.__of__(object)
return subobject
# No view found. Reraise the error raised by __bobo_traverse__
raise e
else:
......@@ -105,9 +105,10 @@ class DefaultPublishTraverse(object):
subobject = getattr(object, name)
else:
# We try to fall back to a view:
subobject = queryMultiAdapter((object, request), Interface, name)
subobject = queryMultiAdapter((object, request), Interface,
name)
if subobject is not None:
return subobject.__of__(object)
return subobject
# And lastly, of there is no view, try acquired attributes, but
# only if there is no __bobo_traverse__:
......@@ -311,8 +312,7 @@ class BaseRequest:
ob2 = namespaceLookup(ns, nm, ob, self)
except TraversalError:
raise KeyError(ob, name)
return ob2.__of__(ob)
return ob2
if name == '.':
return ob
......
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