Jacks_Depression

Jacks_Url Mapping

Posted: 2010-02-26 22:45:56

As website development continues to change. The RESTful ideal is catching on. And a large part of that is making urls easier to understand. Most common servers delegate the folder structure to the website, that is simple from a programming prospective but way outdated. Web servers like WEBrick, Zope and Twisted Web have much better tools to accomplish this new goal. They all seems to fall back to regular expressions or hard coded trees though. No matter what tool I have used, managing urls has never been intuitive enough. Especially when creating APIs. I always let my APIs evolve to what the end user finds most convenient. Which means changing and renaming urls often. And even after you have the url going to the right object, you have to examine it again for validation. I think there should be a much better way of accomplishing this.

What I propose is an xml based url map. Here is an example of one I would use for this blog...

<root>
    <node pattern="post" class="postNode">
        <node pattern="\d+.*" class="singlePost"/>
        <node pattern="*" class="general404"/>
    </node>
    <node pattern="archive" class="archive">
        <node pattern="\d{4}" class="archiveYear">
            <node pattern="\d{2}" class="archiveMonth"/>
            <node pattern="*" class="month404"/>
        </node>
        <node pattern="*" class="general404"/>
    </node>
    <node pattern="popular" class="popular"/>
    <node pattern="*" class="index"/>
</root>

This of course it purely conceptual at this point. It wouldn't been too hard to add validation, then deiced which object will then handle valid and invalid parameters. More to come on this soon.