Thanks a lot Aaron.
I have to learn more FormKit.
I got an error. What's wrong? I can not resolve this error.
------------------------------------------------------------------
from WebKit.Page import Page
from FormKit import Form, BaseChoiceClasses, Fields, Validators
# get the mixin class
from FormKit.FormKitMixIn import FormKitMixIn
# example FormKit servlet
lass Formtest(FormKitMixIn,Page):
def __init__(self):
Page.__init__(self)
f = self.form = Form.Form( )
self.addForm( f )
f.addField( Fields.TextField('text1') )
f.addField( Fields.TextField('text2') )
f.addField(
Fields.WebKitSubmitButton(name="submit",label=" Proceed ") )
def awake(self, transaction):
Page.awake(self, transaction)
bogusData = {
'text1':'Already, some text',
'text2':'text text everywhere',
}
self.form.seed( bogusData )
for f in self.form.fields():
self.session().value(f,f.value().strip())
def getSessionValues(self):
""" restore the form values from the session"""
currentValues = {}
for f in self.form.fields():
if self.session().hasValue(f.name()) and not
self.request().hasValue(f.name()):
#if we have the value in the session, but the
user did not just submit it
currentValues[f.name()] =
self.request().value(f.name())
form.seed( currentValues )
def sleep(self,transaction):
self.resetForms()
Page.sleep(self,transaction)
## form submission and actions - standard WebKit stuff ##
def actions(self):
return ['submit']
def submit(self):
# we don't care about what happens with good data...
self.response().sendRedirect("http://rakan.sytes.net/cgi-bin/wkcgi.cgi/F
ormKitExamples/Formtest2.py")
## output stuff ##
def writeContent(self):
self.writeln("<p>An example with some seed (default)
data.</p>")
self.writeForm()
def writeForm(self):
if self.form.isSuccessful():
self.writeln('''<p>Form successfully posted
'%s'.</p>''' % self.form.values())
else:
self.write( self.form.dump() )
---------------------------------------------------------------------
I got an following.
/home/toshi/Webware/FormKit/Examples/Formtest.py
Traceback (most recent call last):
File "WebKit/Application.py", line 414, in dispatchRequest
self.handleGoodURL(transaction)
File "WebKit/Application.py", line 564, in handleGoodURL
self.awake(transaction)
File "WebKit/Application.py", line 772, in awake
transaction.awake()
File "./WebKit/Transaction.py", line 100, in awake
self._servlet.awake(self)
File "/home/toshi/Webware/FormKit/Examples/Formtest.py", line 46, in
awake
self.session().value(f,f.value().strip())
AttributeError: 'NoneType' object has no attribute 'strip'
Please be patient for beginner.
Toshio Onishi
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss