Invalid URL parsing #5

Merged
merged 1 commit into from Jan 16, 2013

Conversation

Projects
None yet
2 participants
Contributor

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

{code}
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:
continue
if k == 'path':
value = value.lstrip('/')
result[renames.get(k, k)] = value
return result
{code}

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

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

{code}

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

{code}

Contributor

pcdinh commented Jan 16, 2013

Sample nomad.ini

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

Owner

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