In web.database declaration there is dburl param, that is never used.

Maybe, if its not None, the keywords for database initialization
should be taken from parsed url.

In this case I suggest using something similar to parse_rfc1738_args
function found in Django code. I've slightly modified it to support
webpy database keywords:

def parse_rfc1738_args(name):
    pattern = re.compile(r'''
        (?P<dbn>\w+)://
        (?:
            (?P<user>[^:/]*)
            (?::(?P<pw>[^/]*))?
        @)?
        (?:
            (?P<host>[^/:]*)
            (?::(?P<port>[^/]*))?
        )?
        (?:/(?P<db>.*))?
        '''
        , re.X)
    m = pattern.match(name)
    if m is not None:
        components = m.groupdict()
        if components['db'] is not None:
            tokens = components['db'].split('?', 2)
            components['db'] = tokens[0]
            query = (len(tokens) > 1 and
dict(cgi.parse_qsl(tokens[1]))) or None
            if query is not None:
                query = dict([(k.encode('ascii'), query[k]) for k in
query])
                components+= query
        if components['pw'] is not None:
            components['pw'] = urllib.unquote_plus(components['pw'])
        args = dict()
        for k, v in components.iteritems():
            if v:
                args[k] = v
        return args
    else:
        raise Exception("Could not parse rfc1738 URL from string '%s'"
% name)


-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to