program organization question for web development with python

Hans hansyin at
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
mysql database.

1. files organization

I have this in my
print """<a href="">%s</a>""" %

it kind of works but not comfortable to me.

Do I have to use two files( and 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 and then I have to use it in
another file(, 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/ in ()
   20 sql_str = "SELECT * FROM %s " % search_str_list
   21 print "<p>%s</p>" % sql_str
   22 cursor_ptr.execute(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
id=20 '

<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 mailing list