allow view parameters for view names on type concepts

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2459 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-03-17 09:48:18 +00:00
parent 9043c0459e
commit 03fd81a499

View file

@ -333,24 +333,29 @@ class ConceptView(BaseView):
@Lazy
def view(self):
context = self.context
viewName = self.request.get('loops.viewName') or getattr(self, '_viewName', None)
if not viewName:
name = self.request.get('loops.viewName') or getattr(self, '_viewName', None)
if not name:
ti = IType(context).typeInterface
# TODO: check the interface (maybe for a base interface IViewProvider)
# instead of the viewName attribute:
if ti and ti != ITypeConcept and 'viewName' in ti:
typeAdapter = ti(self.context)
viewName = typeAdapter.viewName
if not viewName:
name = typeAdapter.viewName
if not name:
tp = IType(context).typeProvider
if tp:
viewName = ITypeConcept(tp).viewName
if viewName:
name = ITypeConcept(tp).viewName
if name:
if '?' in name:
name, params = name.split('?', 1)
ann = self.request.annotations.get('loops.view', {})
ann['params'] = params
self.request.annotations['loops.view'] = ann
# ??? Would it make sense to use a somehow restricted interface
# that should be provided by the view like IQuery?
#viewInterface = getattr(typeAdapter, 'viewInterface', None) or IQuery
adapter = component.queryMultiAdapter((context, self.request),
name=viewName)
name=name)
if adapter is not None:
return adapter
#elif type provides view: use this