allow more control for NodeView subclasses, e.g. login view

This commit is contained in:
Helmut Merz 2016-07-19 12:17:32 +02:00
parent 3b11a72a81
commit 0dc20ea52f
2 changed files with 11 additions and 3 deletions

View file

@ -196,6 +196,7 @@ class BaseView(GenericView, I18NView, SortableMixin):
icon = None icon = None
modeName = 'view' modeName = 'view'
isToplevel = False isToplevel = False
isVisible = True
def __init__(self, context, request): def __init__(self, context, request):
context = baseObject(context) context = baseObject(context)

View file

@ -1,5 +1,5 @@
# #
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de # Copyright (c) 2016 Helmut Merz helmutm@cy55.de
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -111,7 +111,9 @@ class NodeView(BaseView):
parts.extend(getParts(n)) parts.extend(getParts(n))
return parts return parts
def update(self): def update(self, topLevel=True):
if topLevel and self.view != self:
return self.view.update(False)
result = super(NodeView, self).update() result = super(NodeView, self).update()
self.recordAccess() self.recordAccess()
return result return result
@ -410,8 +412,9 @@ class NodeView(BaseView):
@Lazy @Lazy
def menuItems(self): def menuItems(self):
return [NodeView(child, self.request) items = [NodeView(child, self.request).view
for child in self.context.getMenuItems()] for child in self.context.getMenuItems()]
return [item for item in items if item.isVisible]
@Lazy @Lazy
def parents(self): def parents(self):
@ -439,6 +442,10 @@ class NodeView(BaseView):
def active(self, item): def active(self, item):
return item.context == self.context or item.context in self.parents return item.context == self.context or item.context in self.parents
@Lazy
def authenticationMethod(self):
return self.viewAnnotations.get('auth_method') or 'standard'
# virtual target support # virtual target support
@Lazy @Lazy