diff --git a/menu/README.txt b/menu/README.txt deleted file mode 100644 index 38be69c..0000000 --- a/menu/README.txt +++ /dev/null @@ -1,32 +0,0 @@ -Creating and Rendering Menus -============================ - -We first set up a test and working environment: - - >>> from zope.app import zapi - >>> from zope.app.testing import ztapi - >>> from zope.app.component import site, interfaces - >>> from zope.app.folder import Folder - >>> from cybertools.menu.menu import Menu - >>> from cybertools.menu.interfaces import IMenu - -Set up a site: - - >>> f1 = Folder() - >>> sm = site.LocalSiteManager(f1) - >>> f1.setSiteManager(sm) - >>> default = sm['default'] - -Create a menu and register it: - - >>> m1 = Menu('m1') - >>> default['m1'] = m1 - >>> reg = site.UtilityRegistration('main', IMenu, m1) - >>> default.registrationManager.addRegistration(reg) - 'UtilityRegistration' - >>> reg.status = interfaces.registration.ActiveStatus - >>> zapi.getUtility(IMenu, 'main', context=f1) - Menu('m1') - >>> list(zapi.getUtilitiesFor(IMenu, f1)) - [('main', Menu('m1'))] - \ No newline at end of file diff --git a/menu/__init__.py b/menu/__init__.py deleted file mode 100644 index 4bc90fb..0000000 --- a/menu/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -""" -$Id$ -""" - diff --git a/menu/configure.zcml b/menu/configure.zcml deleted file mode 100644 index 3644b1b..0000000 --- a/menu/configure.zcml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/menu/interfaces.py b/menu/interfaces.py deleted file mode 100644 index f910d4f..0000000 --- a/menu/interfaces.py +++ /dev/null @@ -1,134 +0,0 @@ -# -# Copyright (c) 2005 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 -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -""" -cybertools interface definitions. - -$Id$ -""" - -from zope.interface import Interface -from zope.app.container.interfaces import IOrderedContainer -from zope.app.component.interfaces.registration import IRegisterable - -from zope.schema import Text, TextLine, List, Object, Int - - -class IBaseMenuItem(IOrderedContainer): - """ Base interface with common methods for IMenu and IMenuItem. - """ - - title = TextLine( - title=u'Title', - description=u'Title of the menu or text that will appear on the menu item', - default=u'', - required=True) - - def getMenuItems(): - """ Return sub-menu items contained in this menu or menu item. - """ - - def addMenuItem(id, title, description='', target=None, urlPath=''): - """ Add a new menu item to this item or menu. Return the newly - created menu item. - - This is a convenience method for creating menu structures - programmatically. - """ - - def getParentMenuItem(menu=None, accu=[]): - """ Return the menu or menu item this item is a sub menu item. - - For certain cases of dynamic menu generation it may be - useful to give this method the menu object to which the - parent menu item path may eventually lead, and a list - of already accumulated menu items - in order to avoid - infinite cyclic searches for parent menu items. - """ - - def getMenu(): - """ Return the top-most menu object. - """ - - -class IMenu(IBaseMenuItem, IRegisterable): - """ A Menu is a container for MenuItems and will be shown in a - menu portlet. - """ - - def getActiveMenuItems(context): - """ Return a a tuple with two elements: - [0] list with basic (current) menu item objects that - are associtated with the context. - [1] list with all menu item objects that lead to - the context object. - """ - - def getCorrespondingMenuItems(context): - """ Return the menu items of which context is the target. - """ - - def menuItemPath(): - """ Used for index creation: returns normalized urlPath attribute - for efficiently finding correspondign menu items via the - context object's path. - """ - - -class IMenuItem(IBaseMenuItem): - """ A MenuItem is part of a Menu and usually displayed together - with other MenuItem objects in a menu portlet. - """ - - target = Object(Interface, - title=u'Target', - description=u'Target object this menu item should link to.',) - - urlPath = TextLine( - title=u'URL or Path', - description=u'URL or path that this menu item should link to.', - default=u'', - required=True) - - def getItemUrl(): - """ Return the target URL of this menu item. - """ - - def getTargetUrl(): - """ Return the target URL of this menu item. - """ - - def getTargetObject(): - """ Return the object this menu item points to. - """ - - def isActive(context): - """ Return True if this menu item leads to the context object. - """ - - def isCurrent(context): - """ Return True if this menu item is associated with the - context object. - """ - - def menuItemPath(): - """ Used for index creation: returns normalized urlPath attribute - for efficiently finding correspondign menu items via the - context object's path. - """ - diff --git a/menu/menu.py b/menu/menu.py deleted file mode 100644 index 647dae5..0000000 --- a/menu/menu.py +++ /dev/null @@ -1,64 +0,0 @@ -# -# Copyright (c) 2005 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 -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -""" -Definition of the Menu class. - -$Id$ -""" - -from zope.interface import implements -from zope.app.container.ordered import OrderedContainer -from zope.app import zapi - -from interfaces import IMenu - -class Menu(OrderedContainer): - - implements(IMenu) - - title = u'' - - def __init__(self, name=''): - self.__name__ = name - - def getMenuItems(self): - return () - - def addMenuItem(self, id, title, description='', target=None, urlPath=''): - pass - - def getParentMenuItem(self, menu=None, accu=[]): - return None - - def getMenu(self): - return None - - def getActiveMenuItems(self, context): - return () - - def getCorrespondingMenuItems(self,context): - return () - - def menuItemPath(self): - return '' - - def __repr__(self): - return "%s('%s')" % (self.__class__.__name__, self.__name__) - - \ No newline at end of file diff --git a/menu/tests.py b/menu/tests.py deleted file mode 100755 index 72d67f4..0000000 --- a/menu/tests.py +++ /dev/null @@ -1,48 +0,0 @@ -# $Id$ - -import unittest -from zope.testing.doctestunit import DocFileSuite -from zope.app.testing import ztapi -from zope.interface.verify import verifyClass -#from zope.app.tests.setup import placelessSetUp -from zope.app.testing.setup import placefulSetUp -from zope.app.container.interfaces import IContained -from zope.app.folder import Folder -from zope.app import zapi - -from menu import Menu -from interfaces import IMenu - - -class TestMenu(unittest.TestCase): - "Test methods of the Menu class." - - def setUp(self): -# placelessSetUp() - placefulSetUp() - self.f1 = Folder() - self.f1.__name__ = u'f1' - #self.m1 = Menu() - #self.f1['m1'] = self.m1 - - def tearDown(self): - pass - - # the tests... - - def testInterface(self): - self.assert_(IMenu.providedBy(Menu()), - 'Interface IMenu is not implemented by class Menu.') - self.assert_(IContained.providedBy(Menu()), - 'Interface IContained is not implemented by class Menu.') - verifyClass(IMenu, Menu) - - -def test_suite(): - return unittest.TestSuite(( - unittest.makeSuite(TestMenu), - DocFileSuite('README.txt'), - )) - -if __name__ == '__main__': - unittest.main(defaultTest='test_suite')