[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser - configure.zcml:1.5.14.1 globalbrowsermenuservice.py:1.17.6.1 meta.zcml:1.7.28.1
Peter Simmons
pete@bcmpweb.com
Sun, 13 Jul 2003 05:11:14 -0400
Update of /cvs-repository/Zope3/src/zope/app/publisher/browser
In directory cvs.zope.org:/tmp/cvs-serv29766/src/zope/app/publisher/browser
Modified Files:
Tag: ozzope-menu
configure.zcml globalbrowsermenuservice.py meta.zcml
Log Message:
: ----------------------------------------------------------------------
: This branch contains the beginnings of a recursive menuing system
: Including a drop-down add menu written in javascript. It implements
: extension to the zcml which allows you to link menu items to menus thus
: creating submenus.
: Peter S and Dave F Melbourne Sprint
:
: Committing in .
:
: Modified Files:
: Tag: ozzope-menu
: products.zcml.in src/zope/app/browser/menu.py
: src/zope/app/browser/menus.zcml
: src/zope/app/browser/container/configure.zcml
: src/zope/app/browser/skins/configure.zcml
: src/zope/app/interfaces/publisher/browser.py
: src/zope/app/publisher/browser/configure.zcml
: src/zope/app/publisher/browser/globalbrowsermenuservice.py
: src/zope/app/publisher/browser/meta.zcml
:----------------------------------------------------------------------
=== Zope3/src/zope/app/publisher/browser/configure.zcml 1.5 => 1.5.14.1 ===
--- Zope3/src/zope/app/publisher/browser/configure.zcml:1.5 Tue May 27 08:55:35 2003
+++ Zope3/src/zope/app/publisher/browser/configure.zcml Sun Jul 13 05:10:38 2003
@@ -3,7 +3,6 @@
xmlns:browser='http://namespaces.zope.org/browser'
>
-
<serviceType
id="BrowserMenu"
interface="zope.app.interfaces.publisher.browser.IBrowserMenuService"
=== Zope3/src/zope/app/publisher/browser/globalbrowsermenuservice.py 1.17 => 1.17.6.1 ===
--- Zope3/src/zope/app/publisher/browser/globalbrowsermenuservice.py:1.17 Wed Jul 9 21:35:12 2003
+++ Zope3/src/zope/app/publisher/browser/globalbrowsermenuservice.py Sun Jul 13 05:10:38 2003
@@ -67,7 +67,7 @@
def menuItem(self, menu_id, interface, action, title,
description='', filter_string=None, permission=None,
- ):
+ submenu=None, submenu_prefix="."):
registry = self._registry[menu_id].registry
@@ -83,7 +83,8 @@
checkPermission(None, permission)
data = registry.get(interface) or []
- data.append((action, title, description, filter, permission))
+ data.append((action, title, description, filter, permission,
+ submenu, submenu_prefix))
registry.register(interface, data)
def getMenu(self, menu_id, object, request, max=999999):
@@ -98,7 +99,8 @@
request_url = request.getURL()
for items in registry.getAllForObject(object):
- for action, title, description, filter, permission in items:
+ for action, title, description, filter, permission, \
+ submenu, submenu_prefix in items:
# Make sure we don't repeat a specification for a given title
if title in seen:
@@ -141,27 +143,49 @@
v.__call__
except (Unauthorized, Forbidden):
continue # Skip unauthorized or forbidden
-
+
+ if submenu and submenu_prefix:
+ #traverse to the context
+ v = None
+ try:
+ v = traverser.traverseRelativeURL(
+ request, object, submenu_prefix)
+ import pdb;pdb.set_trace();
+ # XXX
+ # tickle the security proxy's checker
+ # we're assuming that view pages are callable
+ # this is a pretty sound assumption
+ #v.__call__
+ except (Unauthorized, Forbidden):
+ continue # Skip unauthorized or forbidden#Get the menu
+
+ #if we have a context
+ if v is not None:
+ menu = self.getMenu(submenu, v, request)
+ #add it to the result
+ result.append(menu)
+
normalized_action = action
- if action.startswith('@@'):
- normalized_action = action[2:]
-
- if request_url.endswith(action):
- selected='selected'
- elif request_url.endswith('/'+normalized_action):
- selected='selected'
- elif request_url.endswith('++view++'+normalized_action):
- selected='selected'
- else:
- selected=''
-
- result.append({
- 'title': title,
- 'description': description,
- 'action': "%s" % action,
- 'selected': selected
- })
-
+ if action is not None:
+ if action.startswith('@@'):
+ normalized_action = action[2:]
+
+ if request_url.endswith(action):
+ selected='selected'
+ elif request_url.endswith('/'+normalized_action):
+ selected='selected'
+ elif request_url.endswith('++view++'+normalized_action):
+ selected='selected'
+ else:
+ selected=''
+
+ result.append({
+ 'title': title,
+ 'description': description,
+ 'action': "%s" % action,
+ 'selected': selected
+ })
+
if len(result) >= max:
return result
@@ -186,9 +210,10 @@
def menuItemDirective(_context, menu, for_,
action, title, description='', filter=None,
- permission=None):
+ permission=None, submenu=None, submenu_prefix=None):
return menuItemsDirective(_context, menu, for_).menuItem(
- _context, action, title, description, filter, permission)
+ _context, action, title, description, filter, permission,
+ submenu, submenu_prefix)
class menuItemsDirective:
@@ -204,7 +229,7 @@
self.menu = menu
def menuItem(self, _context, action, title, description='',
- filter=None, permission=None):
+ filter=None, permission=None, submenu=None, submenu_prefix=None):
return [
Action(
@@ -212,7 +237,8 @@
self.menu, self.interface, title),
callable = globalBrowserMenuService.menuItem,
args = (self.menu, self.interface,
- action, title, description, filter, permission),
+ action, title, description, filter, permission,
+ submenu, submenu_prefix),
),
]
=== Zope3/src/zope/app/publisher/browser/meta.zcml 1.7 => 1.7.28.1 ===
--- Zope3/src/zope/app/publisher/browser/meta.zcml:1.7 Fri Apr 11 18:15:47 2003
+++ Zope3/src/zope/app/publisher/browser/meta.zcml Sun Jul 13 05:10:38 2003
@@ -802,6 +802,19 @@
and the filter evaluates to a false value.
</description>
</attribute>
+ <attribute name="submenu">
+ <description>
+ The name of the sub menu.
+ </description>
+ </attribute>
+ <attribute name="submenu_prefix">
+ <description>
+ The prefix to add to the actions of the sub menu items.
+
+ e.g. For adding content the current context would be the container
+ and the submenu_prefix would be @@+
+ </description>
+ </attribute>
</subdirective>
</directive>
@@ -815,13 +828,17 @@
<attribute
name="for" />
<attribute
- name="action" />
+ name="action" required="yes" />
<attribute
name="title" />
<attribute
name="description" />
<attribute
name="filter" />
+ <attribute
+ name="submenu" />
+ <attribute
+ name="submenu_prefix" />
</directive>
<directive name="icon" handler=".icon.IconDirective">