You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2021/09/13 20:43:50 UTC
[allura] 09/18: [#8396] upgrade pysolr
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8396
in repository https://gitbox.apache.org/repos/asf/allura.git
commit cf1844a3e7caf62b791cbec7a901d83cd95c3e14
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Fri Sep 10 22:04:57 2021 +0000
[#8396] upgrade pysolr
---
Allura/allura/lib/search.py | 14 ++++++++++++++
Allura/allura/lib/solr.py | 3 +++
requirements.in | 2 +-
requirements.txt | 2 +-
4 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 462ffc2..6d820cf 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -105,6 +105,20 @@ class SearchIndexable(object):
# To do so, we convert markdown into html, and then strip all html tags.
text = g.markdown.convert(text)
doc['text'] = jinja2.Markup.escape(text).striptags()
+
+ # convert some date/time field types to str
+ # from https://github.com/django-haystack/pysolr/blob/1a8887cb2ce1c30ef9d6570704254b4520f8a959/pysolr.py#L692
+ for k, value in doc.items():
+ if hasattr(value, "strftime"):
+ if hasattr(value, "hour"):
+ offset = value.utcoffset()
+ if offset:
+ value = value - offset
+ value = value.replace(tzinfo=None).isoformat() + "Z"
+ else:
+ value = "%sT00:00:00Z" % value.isoformat()
+ doc[k] = value
+
return doc
@classmethod
diff --git a/Allura/allura/lib/solr.py b/Allura/allura/lib/solr.py
index d97141e..de4c536 100644
--- a/Allura/allura/lib/solr.py
+++ b/Allura/allura/lib/solr.py
@@ -17,6 +17,8 @@
from __future__ import unicode_literals
from __future__ import absolute_import
+
+import json
import logging
from tg import config
@@ -145,6 +147,7 @@ class MockSOLR(object):
def add(self, objects):
for o in objects:
o['text'] = ''.join(o['text'])
+ json.dumps(o) # ensure no errors (since pysolr 3.9+ uses json API to solr)
self.db[o['id']] = o
def commit(self):
diff --git a/requirements.in b/requirements.in
index d4bf5af..14b95cd 100644
--- a/requirements.in
+++ b/requirements.in
@@ -34,7 +34,7 @@ profanityfilter==2.0.6
Pygments
pymongo==3.10.1
Pypeline[creole,markdown,textile,rst]
-pysolr==3.6.0
+pysolr
python-dateutil
python-magic
python-oembed
diff --git a/requirements.txt b/requirements.txt
index a987f50..c9cb3d0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -131,7 +131,7 @@ pyparsing==2.4.7
# packaging
pypeline[creole,markdown,rst,textile]==0.5.3
# via -r requirements.in
-pysolr==3.6.0
+pysolr==3.9.0
# via -r requirements.in
python-dateutil==2.8.0
# via