[Checkins] SVN: bobo/branches/d2m.routestack/bobodoctestumentation/src/bobodoctestumentation/more.txt add routestack docs

Michael Haubenwallner michael at d2m.at
Thu Aug 13 02:29:06 EDT 2009


Log message for revision 102728:
  add routestack docs

Changed:
  U   bobo/branches/d2m.routestack/bobodoctestumentation/src/bobodoctestumentation/more.txt

-=-
Modified: bobo/branches/d2m.routestack/bobodoctestumentation/src/bobodoctestumentation/more.txt
===================================================================
--- bobo/branches/d2m.routestack/bobodoctestumentation/src/bobodoctestumentation/more.txt	2009-08-13 06:22:33 UTC (rev 102727)
+++ bobo/branches/d2m.routestack/bobodoctestumentation/src/bobodoctestumentation/more.txt	2009-08-13 06:29:06 UTC (rev 102728)
@@ -792,3 +792,35 @@
    :term:`resource` implementations.  Custom resource implementations
    must implement the resource interface and will provide an order
    using the ``bobo_order`` attribute.  See :ref:`resourceinterface`.
+
+Accessing matched route information
+-----------------------------------
+
+The request URL is matched against all registered routes and their possible
+subroutes. On each successful match, route and path information is collected
+into the request.route_stack object and is now accessible from within every
+function or method::
+
+   bobo_request.routestack.route
+      sequence of already matched routes, route data, path and remaining path
+   
+   bobo_request.routestack.routestack
+      method, returns a sequence of matched routes
+   
+   bobo_request.routestack.pathstack
+      method, returns a sequence of matched paths
+
+Here is an example::
+
+    import bobo
+    
+    @bobo.query('/hello/:name')
+    def hi(bobo_request, name=''):
+        print bobo_request.route_stack.routes
+        return 'Hello %s' % name
+
+We get::
+
+   [{'route_data': {'name': 'world'}, 'path': '/hello/world', 'route': '/hello/:name', 'leftover': ''}]
+
+



More information about the Checkins mailing list