[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces/publisher -
browser.py:1.4
Stephan Richter
srichter at cosmos.phy.tufts.edu
Fri Aug 15 21:45:04 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/interfaces/publisher
In directory cvs.zope.org:/tmp/cvs-serv20171/app/interfaces/publisher
Modified Files:
browser.py
Log Message:
Merging dreamcatcher's TTW Schema branch:
1. Fixed Bug in adding that would cause infinite loops when the menu items
action was not a valif view or factory id.
2. Extended adding to support more complex views. Until now we only
supported constructions like "+/AddView=id". Now you are able to say
"+/AddView/More=id", which means that more information can be carried
in the URL. This can be used in many ways, including multi-page adding
wizards. In my case I needed it to pass in the type of the TTW Schema-
based Content Component.
3. Added Local Menus. This was a pain in the butt, but I think I got a
fairly nice model, where you can create local Menu Services, and Menus
are simply named utilities. When active they are menus in the menu
service. This is very similar to the local interface service and TTW
Schema.
4. Made some modifications to TTW Schema, cleaned up the code and moved
the browser code and interfaces to the places they belong.
5. Added a Content Component Definition utility component, which takes a
Schema and creates a content component for it, including permission
settings and a menu entry. Currently the menu entry is always made to
a local 'add_content' menu. I will change this and make it actually a
screen, where the menu and title of the menu item can be chosen by the
developer. Mmmh, should I add a factory for the definition as well, so
that the content component is also available via python?
6. Added a Content Component Instance component that represents an
instance od a Content Component Definition. You will never directly
encounter this component, since it is automatically used by the adding
code of the Content Component Definition.
7. Cleanups by both dreamcatcher and myself.
That's it. For more details see the branch checkin messages. I now consider
the dreamcatcher-ttwschema-branch closed.
=== Zope3/src/zope/app/interfaces/publisher/browser.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/interfaces/publisher/browser.py:1.3 Sat Dec 28 11:25:45 2002
+++ Zope3/src/zope/app/interfaces/publisher/browser.py Fri Aug 15 20:43:29 2003
@@ -11,14 +11,122 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Browser-Specific Publisher interfaces
+
$Id$
"""
+from zope.app.component.interfacefield import InterfaceField
+from zope.app.security.permission import PermissionField
+from zope.interface import Interface, Attribute
+from zope.schema import TextLine, Text
+
+
+class IBrowserMenuItem(Interface):
+ """A menu item represents one view. These views might be conditioned
+ (using a filter) or being selected to be the default view of the menu."""
+
+ interface = InterfaceField(
+ title=u"Interface",
+ description=u"Specifies the interface this menu item is for.",
+ required=True)
+
+ action = TextLine(
+ title=u"The relative url to use if the item is selected",
+ description=u"""
+ The url is relative to the object the menu is being displayed
+ for.""",
+ required=True)
+
+ title = TextLine(
+ title=u"Title",
+ description=u"The text to be displayed for the menu item",
+ required=True)
+
+ description = Text(
+ title=u"A longer explanation of the menu item",
+ description=u"""
+ A UI may display this with the item or display it when the
+ user requests more assistance.""",
+ required=False)
+
+ permission = PermissionField(
+ title=u"The permission needed access the item",
+ description=u"""
+ This can usually be inferred by the system, however, doing so
+ may be expensive. When displaying a menu, the system tries to
+ traverse to the URLs given in each action to determine whether
+ the url is accessible to the current user. This can be
+ avoided if the permission is given explicitly.""",
+ required=False)
+
+ filter_string = TextLine(
+ title=u"A condition for displaying the menu item",
+ description=u"""
+ The condition is given as a TALES expression. The expression
+ has access to the variables:
+
+ context -- The object the menu is being displayed for
+
+ request -- The browser request
+
+ nothing -- None
+
+ The menu item will not be displayed if there is a filter and
+ the filter evaluates to a false value.""",
+ required=False)
+
+
+class IBrowserMenu(Interface):
+ """A menu can contain a set of views that a represented asa
+ collective."""
+
+ title = TextLine(
+ title=u"Title",
+ description=u"A descriptive title for documentation purposes",
+ required=True)
+
+ description = Text(
+ title=u"A longer explanation of the menu",
+ description=u"""
+ A UI may display this with the item or display it when the
+ user requests more assistance.""",
+ required=False)
+
+ usage = TextLine(
+ title=u"The templates usage top-level variable",
+ description=u"""
+ See the usage documentation in the README.txt in the
+ zope/app/browser/skins directory. If a view is associated with
+ a menu item, the view will get its usage from the menu the
+ menu item is registered to.""",
+ required=False
+ )
+
+ # XXX: Usage as a field does not work well with the addform, so
+ # use this one for now.
+ usage_ = usage
+
+ def getMenuItems(object=None):
+ """Get a list of all menu entries in the usual form:
+
+ (action, title, description, filter, permission)
+
+ If object is None, all items are returned.
+ """
-from zope.interface import Interface
class IBrowserMenuService(Interface):
+ def getAllMenuItems(menu_id, object):
+ """Returns a list of all menu items.
+
+ The output is a list/tuple of:
+ (action, title, description, filter, permission)
+
+ This allows us to make the getMenu() method much less
+ implementation-specific.
+ """
+
def getMenu(menu_id, object, request):
"""Get a browser menu for an object and request
@@ -51,6 +159,17 @@
If no entry can be found, None is returned.
"""
+ def getMenuUsage(self, menu_id):
+ """Return the usage attribute of a specified menu."""
+
+class IGlobalBrowserMenuService(IBrowserMenuService):
+ """The global menu defines some additional methods that make it easier to
+ setup the service (via ZCML for example)."""
+ def menu(self, menu_id, title, description=u'', usage=u''):
+ """Add a new menu to the service."""
+ def menuItem(self, menu_id, interface, action, title,
+ description='', filter_string=None, permission=None):
+ """Add a menu item to a specific menu."""
More information about the Zope3-Checkins
mailing list