[Web-SIG] Announcing bobo

Jim Fulton jim at zope.com
Wed Jun 17 11:46:30 CEST 2009


On Jun 16, 2009, at 11:02 AM, Sergey Schetinin wrote:
...
> indeed there are quite a few
> frameworks / components that do this thing and I kind of don't get why
> people want to write their apps that way. I wonder if Jim or anyone
> else could explain the rationale behind all these URL routing
> libraries. Nobody minds calling functions from other functions --
> that's basics of programming, but for some reason URL dispatching is
> seen as something different. Why?
>
> This is not a criticism, I just really would like to understand this.


Fair enough.  I'm not sure I understand your question.  You need some  
way of mapping URLs onto Python objects that handle them.  You can do  
this on a case by case basis by inspecting a URL and doing some sort  
of ad hoc dispatch in your application. Is that what you mean by  
"calling functions from other functions"?  I've found it useful to  
have a standard mechanism for this that you can use over and over  
without reinventing it each time.

In the original bobo (aka "python object publisher") that I wrote in  
'96, I mapped URLs onto object names in modules.  Later, I extended  
this to use object keys and this grew into a traversal model.  There  
were some difficulties with this approach:

- I needed some way to decide which objects should be URL accessible.  
This led to some less than optimal rules.

- The traversal model mapped well onto an object database, but not so  
well onto relational models.

Many people have taken the approach of providing an explicit separate  
(from code) mechanism of mapping URLs onto their Python objects.   
Usually, this involves having a table mapping URL patterns of some  
sort onto object identifiers. I like explicit. :)

BTW, Chris McDonough provides a nice comparison of traversal and what  
he calls "URL Dispatch" based on a mapping table (Pylons routes) in:

  http://docs.repoze.org/bfg/narr/urlmapping.html#differences-between-traversal-and-url-dispatch

One of my goals with bobo is express web applications with Python as  
much as practical.  While bobo does support the ability to provide an  
external mapping, I definitely wanted to be able to express the  
mapping in the code. One of the advantages of recreating bobo in the  
21st century is that I get to use Python decorators, which provide a  
way to be very explicit about which objects are available to handle  
URLs. (Other web frameworks use decorators for this purpose too. Bobo  
is *not* revolutionary in any way. :)

I find the route syntax used by Rails and Pylons to be very  
appealing.  It uses fairly simple path patterns with placeholders. It  
doesn't use regular expressions.   I don't personally care for the  
controller+action model used by Rails and borrowed by Pylons, so,  
after looking at using Pylon's routes implementation, which I took a  
lot of inspiration from, I went with a slightly different model.   
Basically, a route maps onto an object and when a URL matches a route,  
we call the object. (Of course, there are other details, but they're  
covered by the bobo documentation.)

I hope this helps and that I haven't totally misunderstood your  
original question.

Jim

--
Jim Fulton
Zope Corporation




More information about the Web-SIG mailing list