[Zope] formulator objects

David Bear David.Bear@asu.edu
Thu, 12 Dec 2002 16:36:01 -0700


I'm trying to understand formulator.  From python I want to access each field provided from the formulator form.  I tried the following and get an error.

What methods are available on each of the field objects in a form?  What kind of objects are they?

I was thinking that form.get_fields() returned a dictionary with the field name the dictionary element, and the value of the field the value of the element.  But the following code throws and exception with fnamelist['fname'] -- each name in fnamelist is the name of a field object on my form.  

any pointers?

# script to take formulator form object and spit it back for testing
from Products.Formulator.Errors import ValidationError, FormValidationError
#
form = context.addTechDoc
print "the form object %s" % form
print "==<br>\n"
fieldlist = []
fnamelist = ['author', 'createdON', 'docTitle', 'keywords', 'techDocBody']
print form.get_fields()
print "==<br>\n"
cnt = 0
for field in form.get_fields():
    fieldlist.append(field.get_value(fnamelist[cnt]))
    cnt = cnt + 1
print "the field list <br> \n"
print "%s" % fieldlist
return(printed)

--

David Bear
College of Public Programs/ASU
Mail Code 0803