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 @Lazy
def view(self): def view(self):
context = self.context context = self.context
viewName = self.request.get('loops.viewName') or getattr(self, '_viewName', None) name = self.request.get('loops.viewName') or getattr(self, '_viewName', None)
if not viewName: if not name:
ti = IType(context).typeInterface ti = IType(context).typeInterface
# TODO: check the interface (maybe for a base interface IViewProvider) # TODO: check the interface (maybe for a base interface IViewProvider)
# instead of the viewName attribute: # instead of the viewName attribute:
if ti and ti != ITypeConcept and 'viewName' in ti: if ti and ti != ITypeConcept and 'viewName' in ti:
typeAdapter = ti(self.context) typeAdapter = ti(self.context)
viewName = typeAdapter.viewName name = typeAdapter.viewName
if not viewName: if not name:
tp = IType(context).typeProvider tp = IType(context).typeProvider
if tp: if tp:
viewName = ITypeConcept(tp).viewName name = ITypeConcept(tp).viewName
if 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 # ??? Would it make sense to use a somehow restricted interface
# that should be provided by the view like IQuery? # that should be provided by the view like IQuery?
#viewInterface = getattr(typeAdapter, 'viewInterface', None) or IQuery #viewInterface = getattr(typeAdapter, 'viewInterface', None) or IQuery
adapter = component.queryMultiAdapter((context, self.request), adapter = component.queryMultiAdapter((context, self.request),
name=viewName) name=name)
if adapter is not None: if adapter is not None:
return adapter return adapter
#elif type provides view: use this #elif type provides view: use this