You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by "Ed Summers (JIRA)" <ji...@apache.org> on 2007/09/07 06:36:28 UTC

[jira] Commented: (SOLR-216) Improvements to solr.py

    [ https://issues.apache.org/jira/browse/SOLR-216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12525590 ] 

Ed Summers commented on SOLR-216:
---------------------------------

Thanks guys for this really nice update. I was wrestling with the current solr.py in svn and solr v1.2, and then remembered seeing something on the list about an updated solr client for python.

Anyhow, I was running some unicode through add() in the latest solr.py attached to this issue and noticed that the body isn't being encoded before sending off to httplib.HTTPConnection.request() on line 711:

  self.conn.request('POST', url, body, headers)

This can result in a stack trace like this when sending utf8 over the wire:

Traceback (most recent call last):
  File "./solr_index.py", line 25, in <module>
    solr.add_many([solr_doc])
  File "../../../wdl/solr.py", line 587, in add_many
    return self._update(xstr)
  File "../../../wdl/solr.py", line 653, in _update
    request, self.xmlheaders)
  File "../../../wdl/solr.py", line 711, in _post
    self.conn.request('POST', url, body, headers)
  File "/usr/lib/python2.5/httplib.py", line 862, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.5/httplib.py", line 888, in _send_request
    self.send(body)
  File "/usr/lib/python2.5/httplib.py", line 707, in send
    self.sock.sendall(str)
  File "<string>", line 1, in sendall
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0302' in position 85: ordinal not in range(128)

Changing line 711 to:

  self.conn.request('POST', url, body.encode('utf-8'), headers)

makes the problem go away...

> Improvements to solr.py
> -----------------------
>
>                 Key: SOLR-216
>                 URL: https://issues.apache.org/jira/browse/SOLR-216
>             Project: Solr
>          Issue Type: Improvement
>          Components: clients - python
>    Affects Versions: 1.2
>            Reporter: Jason Cater
>            Assignee: Mike Klaas
>            Priority: Trivial
>         Attachments: solr.py, solr.py
>
>
> I've taken the original solr.py code and extended it to include higher-level functions.
>   * Requires python 2.3+
>   * Supports SSL (https://) schema
>   * Conforms (mostly) to PEP 8 -- the Python Style Guide
>   * Provides a high-level results object with implicit data type conversion
>   * Supports batching of update commands

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.