program organization question for web development with python
hansyin at gmail.com
Thu Sep 16 02:14:14 CEST 2010
I'm new to this area. Please allow me to ask some (maybe stupid)
I'm planning to write a web application which used for searching my
1. files organization
I have this in my main.py:
print """<a href="display_tb.py?id=%s&table=%s&cursor=%s">%s</a>""" %
it kind of works but not comfortable to me.
Do I have to use two files(main.py and display_tb.py)? does that means
each hyper-link needs a single file? Can I put those files together
and then they can share variables,classes, modules, etc?
2. database cursor as parameter?
I created database cursor in my main.py and then I have to use it in
another file(display_tb.py), Can I? I put cursor as a parameter and
try to send it through hyper-link. but it somehow does not work.
error log listed below:
/usr/lib/cgi-bin/display_tb.py in ()
20 sql_str = "SELECT * FROM %s " % search_str_list
21 print "<p>%s</p>" % sql_str
23 result = cursor_ptr.fetchall()
cursor_ptr = '<MySQLdb.cursors.Cursor object at 0xb786b36c>',
cursor_ptr.execute undefined, sql_str = 'SELECT * FROM env_test where
<type 'exceptions.AttributeError'>: 'str' object has no attribute
args = ("'str' object has no attribute 'execute'",)
message = "'str' object has no attribute 'execute'"
More information about the Python-list