diff --git a/browser/common.py b/browser/common.py index a0c78c1..bb88283 100644 --- a/browser/common.py +++ b/browser/common.py @@ -312,7 +312,7 @@ class BaseView(GenericView, I18NView): @Lazy def adapted(self): - return adapted(self.context, self.languageInfo) + return adapted(self.context, self.languageInfo, self.request) @Lazy def baseObject(self): diff --git a/common.py b/common.py index 0857ce8..6de6fb3 100644 --- a/common.py +++ b/common.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2008 Helmut Merz helmutm@cy55.de +# Copyright (c) 2011 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -43,10 +43,11 @@ from loops import util # convenience functions -def adapted(obj, langInfo=None): +def adapted(obj, langInfo=None, request=None): """ Return adapter based on the object type's type interface. """ if isinstance(obj, AdapterBase): + obj.request = request return obj t = IType(obj, None) if t is not None: @@ -57,6 +58,7 @@ def adapted(obj, langInfo=None): if isinstance(adapted, I18NAdapterBase): adapted.languageInfo = langInfo if adapted is not None: + adapted.request = request return adapted return obj @@ -98,7 +100,7 @@ class AdapterBase(object): adapts(IConcept) - _adapterAttributes = ('context', '__parent__',) + _adapterAttributes = ('context', '__parent__', 'request') _contextAttributes = list(IConcept) _noexportAttributes = () _textIndexAttributes = () diff --git a/interfaces.py b/interfaces.py index 85bdefc..c9b05a4 100644 --- a/interfaces.py +++ b/interfaces.py @@ -200,6 +200,7 @@ class ILoopsAdapter(IConceptSchema): context = Attribute('The underlying persistent object.') uid = Attribute('Unique id of the context object.') + request = Attribute('A a mapping with current settings, optional.') def getChildren(): """ Return a collection of child objects provided by the context