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 Wade Leftwich <wa...@okaynetwork.com> on 2007/02/11 03:10:13 UTC
solr.py patch
I'm setting up Solr to work with Zope and Django sites, so was very pleased
to find clients/python/solr.py . I see in the comments that it's a prototype
and subject to change, but here's a small patch.
###
Index: client/python/solr.py
===================================================================
--- client/python/solr.py (revision 505818)
+++ client/python/solr.py (working copy)
@@ -158,12 +158,12 @@
if optimize: xstr='<optimize'
if not waitSearcher: #just handle deviations from the default
if not waitFlush: xstr +=' waitFlush="false" waitSearcher="false"'
- else: xstr += 'waitSearcher="false"'
+ else: xstr += ' waitSearcher="false"'
xstr += '/>'
return self.doUpdateXML(xstr)
def search(self, **params):
- request=urllib.urlencode(params)
+ request=urllib.urlencode(params, doseq=True)
try:
rsp = self.doPost(self.solrBase+'/select', request, self.formheaders)
data = rsp.read()
###
Fixing a typo in SolrConnection.commit(), and letting
SolrConnection.search() take multi-valued params by providing the doseq=True
arg to urllib.urlencode():
In [54]: urlencode({'pepboys':['Manny','Moe','Jack']})
Out[54]: 'pepboys=%5B%27Manny%27%2C+%27Moe%27%2C+%27Jack%27%5D'
In [55]: urlencode({'pepboys':['Manny','Moe','Jack']}, doseq=True)
Out[55]: 'pepboys=Manny&pepboys=Moe&pepboys=Jack'
-- Wade Leftwich
Ithaca, NY
--
View this message in context: http://www.nabble.com/solr.py-patch-tf3207407.html#a8907006
Sent from the Solr - Dev mailing list archive at Nabble.com.
Re: solr.py patch
Posted by Yonik Seeley <yo...@apache.org>.
Thanks Wade, I committed these changes.
-Yonik
On 2/10/07, Wade Leftwich <wa...@okaynetwork.com> wrote:
>
> I'm setting up Solr to work with Zope and Django sites, so was very pleased
> to find clients/python/solr.py . I see in the comments that it's a prototype
> and subject to change, but here's a small patch.
>
> ###
> Index: client/python/solr.py
> ===================================================================
> --- client/python/solr.py (revision 505818)
> +++ client/python/solr.py (working copy)
> @@ -158,12 +158,12 @@
> if optimize: xstr='<optimize'
> if not waitSearcher: #just handle deviations from the default
> if not waitFlush: xstr +=' waitFlush="false" waitSearcher="false"'
> - else: xstr += 'waitSearcher="false"'
> + else: xstr += ' waitSearcher="false"'
> xstr += '/>'
> return self.doUpdateXML(xstr)
>
> def search(self, **params):
> - request=urllib.urlencode(params)
> + request=urllib.urlencode(params, doseq=True)
> try:
> rsp = self.doPost(self.solrBase+'/select', request, self.formheaders)
> data = rsp.read()
> ###
>
> Fixing a typo in SolrConnection.commit(), and letting
> SolrConnection.search() take multi-valued params by providing the doseq=True
> arg to urllib.urlencode():
> In [54]: urlencode({'pepboys':['Manny','Moe','Jack']})
> Out[54]: 'pepboys=%5B%27Manny%27%2C+%27Moe%27%2C+%27Jack%27%5D'
>
> In [55]: urlencode({'pepboys':['Manny','Moe','Jack']}, doseq=True)
> Out[55]: 'pepboys=Manny&pepboys=Moe&pepboys=Jack'
>
>
> -- Wade Leftwich
> Ithaca, NY