[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZMI - IZMIViewService.py:1.1.2.1 ZMIViewService.py:1.1.2.1
Kapil
k_vertigo@yahoo.com
Thu, 31 Jan 2002 17:32:24 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZMI
In directory cvs.zope.org:/tmp/cvs-serv12654
Added Files:
Tag: Zope-3x-branch
IZMIViewService.py ZMIViewService.py
Log Message:
(sprint) Added ZMI View Service/Registry
=== Added File Zope3/lib/python/Zope/App/ZMI/IZMIViewService.py ===
from Interface import Interface
class IZMIViewService(Interface):
def getViews(object):
""" return a sequence of tuples consisting of label, path for zmi
management views of an object """
=== Added File Zope3/lib/python/Zope/App/ZMI/ZMIViewService.py ===
from IZMIViewService import IZMIViewService
from Interface.Util import objectImplements, flattenInterfaces
class ZMIViewService:
__implements__ = IZMIViewService
def __init__(self):
self._reg = {}
def _clear(self):
""" for testing """
self._reg = {}
def registerView(self, interface, label, action):
""" register a zmi view """
views = self._reg.get(interface, [])
views.append((label,action))
self._reg[interface]=views
def getViews(self, object):
""" see inteface docs. returns views in order defined
with tabs from more general interfaces coming after
more specific. """
res = []
obj_interfaces = flattenInterfaces(objectImplements(object))
for interface in obj_interfaces:
res.extend(self._reg.get(interface, ()) )
return res