Invalid URL parsing #5

merged 1 commit into from Jan 16, 2013


None yet
2 participants

pcdinh commented Jan 16, 2013

I just installed nomad in my development server. However it is unable to parse URL defined nomad.ini correctly

My URL: pgsql://my_username:my_password@host_name/database_name

When I run: nomad init I got an exception: no 'root' role defined. I expect that nomad should use "my_username" role instead.

I found a small bug in the code to parse the URL

def path2dict(p, **renames):
'''Convert urlparse result to dict
result = {}
for k in 'hostname port path user password'.split():
value = getattr(p, k, None)
if not value:
if k == 'path':
value = value.lstrip('/')
result[renames.get(k, k)] = value
return result

where p is produced by
p = urlparse.urlparse("pgsql://my_username:my_password@host_name/database_name")

It looks like that you expect "user" is an attribute of p. However, it is not the case


p = urlparse.urlparse("pgsql://my_username:my_password@host_name/database_name")
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'ParseResult' object has no attribute 'user'



pcdinh commented Jan 16, 2013

Sample nomad.ini

engine = dbapi
url = pgsql://x_user:x_password@x_host/database_name


piranha commented Jan 16, 2013

Oh right, not sure how I missed this one. Thanks!

piranha merged commit 11fbe84 into piranha:master Jan 16, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment