How URIs work in Bodhi

**describes the URI munging we do for handling URL paths from document root or from the root uri**

after apache sends off a request to our python processor, in this case via django's mod_python handler, the project's URL config file takes over. this file is basically a list of all possible requests and their corresponding actions. i will not go into detail about the inner workings of this spell book, but should point out that it is hierarchical, in that django begins at the top and moves down through to find the appropriate response to any given request. this is important for our application since it depends on funky regex incantation to munge the URI for all requests that do not match any of the lines above it, including the line for the home page, which is the second to last one in the list: (r'^%s$' % (root_url), 'iris.cms.views.index'), the last one in the list is our munge incantation, which i called paint. the regular expression (?P[^?#]*) grabs the entire path after ROOT_URL and passes it as a slug to the cms view called "paint": (r'^%s(?P[^?#]*)' % (root_url), 'iris.cms.views.paint'), this entry must be last in order for the paint view to work properly, as any request that does not match a valid page in the view is returned as a 404 page not found. for example, for a request like /bodhi/about/staff/roser/ we would see about/staff/roser/ passed to the paint view. the paint view then matches the value passed to it with the "path" field of the page by traversing the child/parent relationship of the URI and returns the "body" content for that page. there is a bit of a problem with the page part, as we currently have the name "body" hardcoded into the application, as we now only permit one page part per page. in the future, if we allow more than one page part, we will have to modify the architecture a bit, taking into consideration that users might not have created a "body" page part. or maybe we must have "body" as the default first page part for any given page and it cannot be delete. anyway, we will cross that bridge when we come upon it. 0 Comments, 0 trackbacks (Trackback URL)

Comments have been deactivated for this entry.