fix storage of nodeView in request; provide baseObject utility function for unwrapping an adapter if necessary

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3633 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2009-11-20 14:08:21 +00:00
parent 4b32972ef0
commit 0a4f1de2eb
2 changed files with 9 additions and 4 deletions

View file

@ -76,10 +76,8 @@ class NodeView(BaseView):
def __init__(self, context, request): def __init__(self, context, request):
super(NodeView, self).__init__(context, request) super(NodeView, self).__init__(context, request)
viewAnnotations = request.annotations.setdefault('loops.view', {}) self.viewAnnotations.setdefault('nodeView', self)
viewAnnotations['nodeView'] = self self.viewAnnotations.setdefault('node', self.context)
if viewAnnotations.get('node') is None:
viewAnnotations['node'] = self.context
viewConfig = getViewConfiguration(context, request) viewConfig = getViewConfiguration(context, request)
self.setSkin(viewConfig.get('skinName')) self.setSkin(viewConfig.get('skinName'))

View file

@ -46,6 +46,8 @@ from loops import util
def adapted(obj, langInfo=None): def adapted(obj, langInfo=None):
""" Return adapter based on the object type's type interface. """ Return adapter based on the object type's type interface.
""" """
if isinstance(obj, AdapterBase):
return obj
t = IType(obj, None) t = IType(obj, None)
if t is not None: if t is not None:
ti = t.typeInterface ti = t.typeInterface
@ -58,6 +60,11 @@ def adapted(obj, langInfo=None):
return adapted return adapted
return obj return obj
def baseObject(obj):
if isinstance(obj, AdapterBase):
return obj.context
return obj
# helper functions for specifying automatic attribute handling # helper functions for specifying automatic attribute handling