You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by Patty <pa...@gmail.com> on 2006/03/15 23:34:00 UTC
mod-python error
Hi,
I'm really hoping someone can help me understand what is wrong with this piece
of code.
Thanks,
Patty
This is how I call my function:
http://hostname/mptest/ask.py/ask?host=ahost&target=atarget
***************************************************************************
This is the piece of code:
# Connect to the database
conn = MySQLdb.connect(host = "localhost", user = "root", passwd = "",
db ="ants_control_center")
cursor = conn.cursor()
def ask(req, host, target):
gtarget = "%s" % target
ghost = "%s" % host
cursor.execute(""" #This is line 18
SELECT date FROM targets WHERE target_name = %s""",(gtarget))
result = cursor.fetchone()
conn.commit()
if ((gtarget == 'bl') | (gtarget == 'bs') | (gtarget == 'nl') |
(gtarget == 'bx')):
cursor.execute("UPDATE targets SET date = %s WHERE target_name = %s",
(datetime.date.today(),gtarget))
conn.commit()
return compare_hosts(ghost,gtarget)
# This one takes care of the rest
if (datetime.date.today() == result[0]):
return compare_hosts(ghost,gtarget)
else:
return set_host_percentage(ghost,gtarget)
***************************************************************************
This is the error I'm getting:
<pre>
Mod_python error: "PythonHandler mod_python.publisher"
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in
HandlerDispatch
result = object(req)
File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 136, in
handler
result = util.apply_fs_data(object, req.form, req=req)
File "/usr/lib/python2.3/site-packages/mod_python/util.py", line 361, in
apply_fs_data
return object(**args)
File "/var/www/html/mptest/ask.py", line 18, in ask
cursor.execute("""
File "/usr/lib/python2.3/site-packages/MySQLdb/cursors.py", line 137, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 33, in
defaulterrorhandler
raise errorclass, errorvalue
AttributeError: 'NoneType' object has no attribute 'literal'
</pre>
Re: mod-python error
Posted by Joseph Barillari <jo...@mit.edu>.
That looks like an SQL error, rather than an MP error. I'd try calling
it without MP present (with the same arguments, of course...).
Joe
On Wed, Mar 15, 2006 at 10:34:00PM +0000, Patty wrote:
> Hi,
> I'm really hoping someone can help me understand what is wrong with this piece
> of code.
> Thanks,
> Patty
>
> This is how I call my function:
> http://hostname/mptest/ask.py/ask?host=ahost&target=atarget
>
> ***************************************************************************
> This is the piece of code:
>
> # Connect to the database
> conn = MySQLdb.connect(host = "localhost", user = "root", passwd = "",
> db ="ants_control_center")
> cursor = conn.cursor()
>
>
> def ask(req, host, target):
>
> gtarget = "%s" % target
> ghost = "%s" % host
> cursor.execute(""" #This is line 18
> SELECT date FROM targets WHERE target_name = %s""",(gtarget))
> result = cursor.fetchone()
> conn.commit()
>
> if ((gtarget == 'bl') | (gtarget == 'bs') | (gtarget == 'nl') |
> (gtarget == 'bx')):
> cursor.execute("UPDATE targets SET date = %s WHERE target_name = %s",
> (datetime.date.today(),gtarget))
> conn.commit()
> return compare_hosts(ghost,gtarget)
>
> # This one takes care of the rest
> if (datetime.date.today() == result[0]):
> return compare_hosts(ghost,gtarget)
> else:
> return set_host_percentage(ghost,gtarget)
>
> ***************************************************************************
>
> This is the error I'm getting:
>
> <pre>
> Mod_python error: "PythonHandler mod_python.publisher"
>
> Traceback (most recent call last):
>
> File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in
> HandlerDispatch
> result = object(req)
>
> File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 136, in
> handler
> result = util.apply_fs_data(object, req.form, req=req)
>
> File "/usr/lib/python2.3/site-packages/mod_python/util.py", line 361, in
> apply_fs_data
> return object(**args)
>
> File "/var/www/html/mptest/ask.py", line 18, in ask
> cursor.execute("""
>
> File "/usr/lib/python2.3/site-packages/MySQLdb/cursors.py", line 137, in execute
> self.errorhandler(self, exc, value)
>
> File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 33, in
> defaulterrorhandler
> raise errorclass, errorvalue
>
> AttributeError: 'NoneType' object has no attribute 'literal'
>
> </pre>
>
>
--
Joseph Barillari
joeb@mit.edu
107 Ave. Louis Pasteur, Vandy Box 121, Boston, MA 02115
617-519-9250 (mobile)