Repository: LMFDB/lmfdb

Issue:
Download of Weil polynomials fails
From http://www.lmfdb.org/Variety/Abelian/Fq/5/2/ all three of the download buttons produce a server error.  The same is true on beta so this needs to be fixed.


Discussion:

Resolving patch:
diff --git a/lmfdb/abvar/fq/main.py b/lmfdb/abvar/fq/main.py
--- a/lmfdb/abvar/fq/main.py
+++ b/lmfdb/abvar/fq/main.py
@@ -323,7 +323,7 @@ def download_search(info):
     s += '\\\n'
     res = db().find(ast.literal_eval(info["query"]))
     for f in res:
-        poly = R([int(c) for c in f['polynomial']])
+        poly = R([int(c) for c in f['poly'].split(" ")])
         s += str(poly) + ',\\\n'
     s = s[:-3]
     s += ']\n'
@@ -334,9 +334,7 @@ def download_search(info):
     strIO = StringIO.StringIO()
     strIO.write(s)
     strIO.seek(0)
-    return send_file(strIO,
-                     attachment_filename=filename,
-                     as_attachment=True)
+    return send_file(strIO, attachment_filename=filename, as_attachment=True, add_etags=False)
 
 @abvarfq_page.route("/Completeness")
 def completeness_page():
diff --git a/lmfdb/base.py b/lmfdb/base.py
--- a/lmfdb/base.py
+++ b/lmfdb/base.py
@@ -119,13 +119,13 @@ def makeDBConnection():
         if pymongo.version_tuple[0] >= 3:
             cursor = _mongo_C.knowledge.knowls.find({},{'_id':True}).limit(-1)
             list(cursor)
-            logging.info("MongoClient conection is reading from: %s" % (cursor.address,));
+            logging.info("MongoClient connection is reading from: %s" % (cursor.address,));
         elif _mongo_kwargs.get("replicaset",None) is not None:
             cursor = _mongo_C.knowledge.knowls.find({},{'_id':True}).limit(-1)
             list(cursor)
             logging.info("MongoReplicaSetClient connection is reading from: %s" % (cursor.conn_id,));
         else:
-            logging.info("MongoClient conection is reading from: %s" % (_mongo_C.host,));
+            logging.info("MongoClient connection is reading from: %s" % (_mongo_C.host,));
     except Exception as err:
         logging.info("connection attempt failed: %s", err)
         _mongo_C = None


Test patch:
diff --git a/lmfdb/abvar/fq/test_av.py b/lmfdb/abvar/fq/test_av.py
--- a/lmfdb/abvar/fq/test_av.py
+++ b/lmfdb/abvar/fq/test_av.py
@@ -8,7 +8,6 @@ def check_args(self, path, text):
     def not_check_args(self, path, text):
         assert not(text in self.tc.get(path, follow_redirects=True).data)
 
-
     # All tests should pass
     def test_polynomial(self):
         r"""
@@ -91,7 +90,8 @@ def test_newton_polygon_plot(self):
         Check that the plot of the Newton polygon is included and computed correctly
         """
         page = self.tc.get("/Variety/Abelian/Fq/2/4/ad_g").data
-        # The following is part of the base64 encoded image of the Newton polygon for this isogeny class.
+        # The following is part of the base64 encoded image of the Newton
+        # polygon for this isogeny class.
         assert "4S8eKLeWaDFgkQAKBLwgPyECAAQFeEB%2BQlQACALggPKIMA" in page
 
     def test_circle_plot(self):
@@ -99,7 +99,8 @@ def test_circle_plot(self):
         Check that the plot showing the roots of the Weil polynomial displays correctly
         """
         page = self.tc.get("/Variety/Abelian/Fq/2/4/ad_g").data
-        # The following is part of the base64 encoded image of the circle plot for this isogeny class.
+        # The following is part of the base64 encoded image of the circle plot
+        # for this isogeny class.
         assert "gMA4O7CwsJ06NAhDqLDaVBAYEkcQAcA4EccRIezo" in page
 
     def test_property_box(self):
@@ -116,3 +117,17 @@ def test_split_Frobenius_angles(self):
         """
         page = self.tc.get("/Variety/Abelian/Fq/2/4/ad_g").data
         assert r"$\pm0.15043295046$, $\pm0.544835058382$" in page
+
+    def test_av_download(self):
+        r"""
+        Test downloading on search results page.
+        """
+        response = self.tc.get('Variety/Abelian/Fq/5/2/?Submit=sage&download=1&query=%7B%27q%27%3A+2%2C+%27g%27%3A+5%7D')
+        self.assertTrue('Below is a list' in response.data)
+        self.assertTrue('32*x^10' in response.data)
+        response = self.tc.get('Variety/Abelian/Fq/5/2/?Submit=gp&download=1&query=%7B%27q%27%3A+2%2C+%27g%27%3A+5%7D')
+        self.assertTrue('Below is a list' in response.data)
+        self.assertTrue('32*x^10' in response.data)
+        response = self.tc.get('Variety/Abelian/Fq/5/2/?Submit=magma&download=1&query=%7B%27q%27%3A+2%2C+%27g%27%3A+5%7D')
+        self.assertTrue('Below is a list' in response.data)
+        self.assertTrue('32*x^10' in response.data)