You are not logged in Log in Join
You are here: Home » Members » shalabh » A Traversable Mixin Class » dc_view

Log in
Name

Password

 
 


Dublin Core Elements

The Dublin Core metadata element set is a standard for cross-domain information resource description.
Element Description Value
Identifier resource ID http://old.zope.org/Members/shalabh/TraversableMixin
Title resource name A Traversable Mixin Class
Description resource summary A Traversable Mixin Class Make this a base class of your ZClass to make them 'traversable'. A Traversable object is an object that can access components of the url as parameters. What does it mean? Consider the following URL: http://www.zopesite.com/MyTraversableMethod/foo/bar</code> In the usual scenario, zope would search for *objects* called 'foo' and 'bar'. However, if 'MyTraversalMethod' is a traversable method, it can *consume* components of the url as parameters. In the above example, 'MyTraversalMethod' would have access to the strings '"foo"' and '"bar"' which it can use for any purpose. So where you earlier used: /Issues?priority=high&status=open you can now use: /Issues/HighPriority/Open Using this mixin class, you can make any other class traversable. Works best with DTMLDocument and DTMLMethod. Usage Notes - Creating the ZClass - Always make this the _last_ base class for your ZClass - After creating a ZClass you need to add a view: 1. Go to the 'Views' tab of the ZClass 2. Type 'Traverse' for the view name 3. Select 'manage_traverseform' from the dropdown list of available views - The Mixin needs two properties to work. The names of these properties are 'mandatoryParameters' and 'optionalParameters'. You need to set them on each instance, before you can use the traversal facilities on it. You should tweak the ZClass_add methods to autmatically set these properties (to 0) every time a new instance is created. Usage Notes - Using the ZClass - Specify the number of mandatory and optional paramters the method should consume. Mandatory parameters are *always consumed* from the url. Optional parameters are consumed after that only if there is no object that can be traversed with the same id. By default both the parameters are zero thus no url components are consumed. Use the Traversal tab through the management interface to specify the number of parameters. - Now in any method of your object you have a list available through the REQUEST['traverse_param'] variable. For example, if your object is a DTMLMethod, you can type '<dtml-var traverse_param>' to see the list of parameters consumed from the url. Why the mandatory and optional parameters? Consider a folder F with: - An object called 'foo' - A Traversable DTML Method called 'MyTMeth' Say you access the url '/F/MyTMeth/foo'. Should 'foo' be interpreted as the acquired object or should it be used as a parameter for 'MyTMeth'. To resolve this ambiguity there is the concept of *mandatory* and *optional* parameters.
Creator resource creator shalabh
Date default date 2001-02-26 10:04:38
Format resource format text/html
Type resource type Software Package
Subject resource keywords Navigational
Contributors resource collaborators
Language resource language
Publisher resource publisher No publisher
Rights resource copyright


Additional Zope Elements

Element Description Value
CreationDate date resource created 2001-02-26 10:04:38
ModificationDate date resource last modified 2001-02-26 10:04:38
EffectiveDate date resource becomes effective None
ExpirationDate date resource expires None

Backlinks: via Google / Technorati