Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into docs-restructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Jun 1, 2015
2 parents c1513af + 798b717 commit 457eae4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGES.rst
Expand Up @@ -13,6 +13,10 @@ Changelog
- Added context to search utility. This allows query to be used in AJAX calls.
[tomgross]

- Use GET method in spell check request (as it's an idempotent request which
does not affect server state)
[reinhardt]


4.1.0 (2015-02-19)
------------------
Expand Down
4 changes: 2 additions & 2 deletions src/collective/solr/browser/suggest.py
Expand Up @@ -25,8 +25,8 @@ def __call__(self):
params['wt'] = 'json'

params = urllib.urlencode(params, doseq=True)
response = connection.doPost(
connection.solrBase + '/spell?' + params, '', {})
response = connection.doGet(
connection.solrBase + '/spell?' + params, {})
results = json.loads(response.read())

# Check for spellcheck
Expand Down
10 changes: 8 additions & 2 deletions src/collective/solr/solr.py
Expand Up @@ -122,8 +122,14 @@ def setTimeout(self, timeout):
self.conn.setTimeout(timeout)

def doPost(self, url, body, headers):
return self.doGetOrPost('POST', url, body, headers)

def doGet(self, url, headers):
return self.doGetOrPost('GET', url, '', headers)

def doGetOrPost(self, method, url, body, headers):
try:
self.conn.request('POST', url, body, headers)
self.conn.request(method, url, body, headers)
return self.__errcheck(self.conn.getresponse())
except (
socket.error, httplib.CannotSendRequest,
Expand All @@ -136,7 +142,7 @@ def doPost(self, url, body, headers):
# HTTPConnection object can get in a bad state (seems like they
# might be "ghosted" in the zodb).
self.__reconnect()
self.conn.request('POST', url, body, headers)
self.conn.request(method, url, body, headers)
return self.__errcheck(self.conn.getresponse())

def doUpdateXML(self, request):
Expand Down
3 changes: 3 additions & 0 deletions src/collective/solr/tests/test_browser_suggest.py
Expand Up @@ -58,6 +58,9 @@ class MockConnection():
def doPost(self, url, foo, bar):
return MockResponse()

def doGet(self, url, bar):
return MockResponse()


class MockSolrConnectionManager():

Expand Down

0 comments on commit 457eae4

Please sign in to comment.