asterisk / ari-py

Library for accessing the Asterisk REST Interface
Other
151 stars 106 forks source link

Proper handle unicode connection string #12

Closed litnimax closed 9 years ago

litnimax commented 10 years ago

When you store ari connection info in database it is usually returned as python unicode string and ari-py fails to manage it:

>>> client = ari.connect(u'http://localhost:8088', u'dialer', u'test')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/ari/__init__.py", line 26, in connect
    return Client(base_url, http_client)
  File "/usr/local/lib/python2.7/dist-packages/ari/client.py", line 29, in __init__
    url, http_client=http_client)
  File "/usr/local/lib/python2.7/dist-packages/swaggerpy/client.py", line 180, in __init__
    log.debug("Loading from %s" % url_or_resource.get('basePath'))
AttributeError: 'unicode' object has no attribute 'get'

>>> client = ari.connect('http://localhost:8088', 'dialer', 'test')
>>> 
matt-jordan commented 9 years ago

I disagree that this is something ari-py should be doing. It should be acting on standard Python 2.x strings, which are ASCII. Passing a library unicode and expecting it to "just work" is not something that any library would recommend.

In fact, I'd go further and say that encouraging someone to pass unfiltered data from an external system directly into Asterisk is a bad idea in the first place.

Now, if someone wants to add full unicode support, that's fine - but that's a feature or enhancement, and certainly not a bug.