I'm still not very clear on the "recommended" way to create
forms in awake(), since the way I'm doing it, by manipulating
self._forms, doesn't seem very natural.  If this is the right
way, I can create an example for your Examples folder.  If
not, and you find the time before the next release, an example
of a form created in awake() would be helpful, I think.  :)

Thanks!

Not sure if I am doing it the "correct way" but I have a page where the form is generated on the fly each time.


The form only needs to exist if it needs to be rendered for the user, or if it needs 
to be validated.
I am not using the mixin and doing all the processing explicitly.

So I have base class w/ def initForm(self):
'''Initialize the base form. This should be the same for all classes, there is a hook
to init2 to add controls specific to the report being created.'''
f1 = self.form1 = Form.Form( )
f1._setFormID(self.reportID)
f1.addField( Fields.SelectField('rowsPerPage', label="Records per Page") )
.....


Then if the user send forminfo I do:

   def showReport(self)
       self.initForm()
       fields = self.request().fields()
       self.form1.process( fields )
        # save the user values
       currentValues = {}
       for f in self.form1.fields():
           currentValues[f.name()] = f.value()
       formValid = self.form1.isSuccessful()
       if not formValid:
           f1 = self.form1
            put back the user values
           f1.seed(currentValues)
           self.writeForm('Error')
       else:
           self.writeReportHTML()

This has the disadvantage of building up the form class each run.
You may want to use some instance caching in initForm to save the form between runs, 
and then call something to .sleep each form in servlet.sleep.

There are some good examples of this type of caching relating to Cheetah templates.

-Aaron




------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to