Huy wrote:
Just wondering if Webware could do cherrypy like url mapping. Does the new WSGIKit support this either ?

In SVN there's URLParser, which allows for a number of kinds of URL parsing overrides -- look at WebKit.URLParser.URLParser.parseInit.


WSGIKit has a few hooks as well, but we're still figuring it out. For the to-do sample app, we parse URLs so that if the first component isn't recognized, it's considered a username, but if it is recognized then we serve it directly. So...

/check.png -> check.png
/list      -> list.py (username=None)
/bob/list  -> list.py (username='bob')

Here's the code in WSGIKit/examples/todo/__init__.py:


from wsgikit import wsgilib

def not_found_hook(environ, start_response):

    p = environ['wsgikit.urlparser.not_found_parser']
    username, rest = wsgilib.path_info_split(
        environ.get('PATH_INFO', ''))
    if username is None:
        return p.not_found(environ, start_response)
    environ['app.user'] = username
    environ['SCRIPT_NAME'] += '/' + username
    environ['PATH_INFO'] = rest
    return p(environ, start_response)



--
Ian Bicking  /  [EMAIL PROTECTED]  / http://blog.ianbicking.org


------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Webware-discuss mailing list Webware-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to