It looks good, but if you want to use the built-in action handler then
you have to make your SUBMIT button _action_ACTIONAME
like:
<input type="SUBMIT" name="_action_addrec" value="Add A Record">
and then in the servlet:
def actions(self):
return ['addrec']
def preAction(self,actionName):
'''Run some code before ANY action'''
if (self.request().hasField('curPos')):
curPos = int(self.request().field('curPos'))
else:
curPos = 0
def postAction(self,actionName):
'''Run code AFTER any action'''
pass
def addrec(self):
self.writeln(''recodrd added'')
-Aaron
Bogdan wrote:
I have Webaware 0.7 running on Apache 1.3.26 on Debian linux. I'm a
newbie in python and webware, and it is difficult for me to browse the
sources, so can somebody give me an example and/or advice about how to
handle forms. Here is my code:
from WebKit.Page import Page
from Cheetah.Template import Template
import MySQLdb
tempDef="""
<TABLE bgcolor="#07e1f9" width=80% align="center">
#for $i in $row
<tr>
#for $k in $i
<td>$k</td>
#end for
</tr>
#end for
</table>
<BR>
<form action="index.py" method=POST enctype="multipart/form-data">
<input type="text" name="filename"><BR>
<input type="SUBMIT" name="_action_" value="addrec">
</form>
</body></html>
"""
class index(Page):
def __init__(self):
Page.__init__(self)
self.compTemplate = Template(tempDef)
def title(self):
return "Test!"
def writeContent(self):
conn=MySQLdb.connect(db="test", user="root")
cur=conn.cursor()
cur.execute("""SELECT * from userlist;""")
t = self.compTemplate
t.row = cur.fetchall()
self.writeln(t)
cur.close()
conn.close()
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss