Figured it out, I messed up when relaying the absolute_url to my javascript and that caused an undefined URL. Thanks for helping me get that straightened out and giving me advice on how I should and should not manage database connections. Like I said I'm just an intern and any advice is greatly appreciated.
On 12/15/10 12:56 PM, "Andreas Jung" <[email protected]> wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >Please stay on the list! > >""" >it still gives an error >""" > >Which error? > >- -aj > >- -------- Original Message -------- >From: Keith Thompson <[email protected]> >Subject: Re: [Product-Developers] AJAX "POST" to specific function in >product BrowserView Class >Date: Wed, 15 Dec 2010 12:32:10 -0500 >To: [email protected] <[email protected]> > >I'll look into using a ZMySQLDA, I would really rather not deal with >SQLAlchemy's syntax when I can simply use real SQL statements through >MySQLdb. I did get the URL to work without changing the structure of my >product, by having the page-template relay the absolute_url to my >javascript and appending my view ('locator_view') to the end of that, but >it still gives an error. So I'm assuming that my next issue is the data >property. > >On 12/15/10 12:20 PM, "Andreas Jung" <[email protected]> wrote: > >> kthomps17 wrote: >> >> >>> def searchDealers(l1, l2, r): >>> l1 = str(l1) >>> l2 = str(l2) >>> r = str(r) >>> settings = getUtility(IDatabaseSettings) >>> mydb = mysql.connect(host=settings.hostname, >>> user=settings.username, >>> passwd=settings.password, >>> db=settings.database) >>> cur = mydb.cursor() >>> cur.execute('SELECT name, address, lat, lng, ( 3959 * acos( >>>cos( >>> radians('+l1+') ) * cos( radians( lat ) ) * cos( radians( lng ) - >>> radians('+l2+') ) + sin( radians('+l1+') ) * sin( radians( lat ) ) ) ) >>>AS >>> distance FROM dealers HAVING distance < '+r+' ORDER BY distance LIMIT 0 >>>, >>> 25') >>> results = cur.fetchall() >>> doc = Document() >>> markers = doc.createElement("markers") >>> doc.appendChild(markers) >>> for row in results: >>> marker = doc.createElement("marker") >>> marker.setAttribute("name", row[0]) >>> marker.setAttribute("address", row[1]) >>> marker.setAttribute("lat", str(row[2])) >>> marker.setAttribute("lng", str(row[3])) >>> marker.setAttribute("distance", str(row[4])) >>> markers.appendChild(marker) >>> mydb.close() >>> return doc.toprettyxml() >> >> >> >> >> Apart from that: managing your DB connection yourself is very bad-style. >> Better use a related database adapter like ZMySQLDA or SQLAlchemyDA >> dealing with connection polling, reconnection etc. for your. Never ever >> do database handling yourself. >> >> -aj >-----BEGIN PGP SIGNATURE----- >Version: GnuPG v1.4.11 (Darwin) >Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > >iQGUBAEBAgAGBQJNCQFaAAoJEADcfz7u4AZjv3ELvjrxwaqi83sgVuwIhsjKZxiA >0jXcXnHgWlNl96l6P2yHMSW7yiIhoPH6VN5g9At3nFeaiPbKYX1Lt+ag9lomvE9y >MVuu1/QLElLiQkIa4g1xnj31khEPmhma6Dn21/8Z9oImtllwX7Zamg/WKkmCWEWy >OVyYeRs9iW+vRs/oXLkMAPfvCoaKdLzxlYZBe9oa8aCM8wfOv8+9tgF0poF0RHGT >wXONYixoXYkbF5C0MMGnmqrszSF6uF0Sp1y1GaONLOFa/NNfUsFYJsc1TXz4Wlfc >7z7zYdM1ggaBoc+3yRN5+u2bv7xpgUBz3duf4BpeMgz6hXx5GzxrBdMea2nZSiuY >MpcDJwZSbY+PF9nA6BhF6rMJaxjslAZNnpSVo8Btqk+WvJPtH5MFfdR4vwnYTJ5n >DxY+gNYJGWwOusDtt7M4VOIig24zo8nPOyMfjhGWxrmmO632zqfy2OcRjv8r7S5j >sspME8jEMfTwZAQv9E/TfHq2SxR//mg= >=hf33 >-----END PGP SIGNATURE----- _______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
