removed cybertools/menu package

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1112 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2006-03-05 16:02:58 +00:00
parent 64c4215033
commit ed8c66ce15
6 changed files with 0 additions and 352 deletions

View file

@ -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'))]

View file

@ -1,4 +0,0 @@
"""
$Id$
"""

View file

@ -1,70 +0,0 @@
<!-- $Id$ -->
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="zope"
>
<!-- Content declarations -->
<interface
interface=".interfaces.IMenu"
type="zope.app.content.interfaces.IContentType" />
<content class=".menu.Menu">
<implements
interface="zope.app.utility.interfaces.ILocalUtility
zope.app.annotation.interfaces.IAttributeAnnotatable" />
<factory
id="cybertools.Menu"
description="A configurable menu" />
<require
permission="zope.View"
interface=".interfaces.IMenu" />
<require
permission="zope.ManageContent"
set_schema=".interfaces.IMenu" />
</content>
<!-- Register views and skin stuff -->
<!--<include package=".browser" />-->
<browser:tool
interface="cybertools.menu.interfaces.IMenu"
title="Menu"
description="A Menu allows you to add menu items that are then shown in a portlet"
/>
<browser:addform
label="Add Menu"
name="AddMenu.html"
schema="cybertools.menu.interfaces.IMenu"
content_factory="cybertools.menu.Menu"
fields="title"
permission="zope.ManageContent"
/>
<browser:addMenuItem
class="cybertools.menu.Menu"
title="Menu"
permission="zope.ManageContent"
view="AddMenu.html"
/>
<browser:editform
label="Edit Menu"
name="edit.html"
schema="cybertools.menu.interfaces.IMenu"
for="cybertools.menu.interfaces.IMenu"
permission="zope.ManageContent"
menu="zmi_views" title="Edit"
fields="title"
/>
</configure>

View file

@ -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.
"""

View file

@ -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__)

View file

@ -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')