On Jan 2, 12:16 pm, casibbald <[email protected]> wrote:
> On Jan 1, 1:10 pm, "Diez B. Roggisch" <[email protected]> wrote:
>
>
>
>
>
> > casibbald schrieb:
>
> > > On Dec 31 2009, 6:13 pm, "Diez B. Roggisch" <[email protected]> wrote:
> > >> casibbald schrieb:
>
> > >>> Hi All,
> > >>> I have something strange going on with my forms, they seem to
> > >>> misbehave and i don't know if its my code, or something with forms.
> > >>> The strange thing is, if i get Turbogears to reload anything by adding
> > >>> a comment to a file, i can visit the page and the form works again.
> > >>> but the forms vanish again.
> > >>> The following is a form rendered correctly:
> > >>>http://prontoapps.com/images/formItemShowing.png
> > >>> The following is the form if the page is refreshed, or visited from
> > >>> another browser tab/machine:
> > >>>http://prontoapps.com/images/formItemsVanish.png
> > >>> The application does not have a DB, and is designed to manipulate
> > >>> files on the filesystem.
> > >>> Looking forward to someone shedding light on this.
> > >> You want your @validate-decorator have the applicationControl-action as
> > >> error_handler.
>
> > >> Diez
>
> > > Hi Diez,
>
> > > Thanks for your response.
>
> > > I have updated as below, but still have the same problem. Could there
> > > be another parameter missing?
>
> > >     @expose('webdeploy.templates.applicationControl')
> > >     def applicationControl(self, **kw):
> > >         """Handle the 'applicationControl' page."""
> > >         tmpl_context.form = create_applicationControlForm
> > >         return dict(page='applicationControl',
> > > control_options='controlApplicationOptions',
> > > control_actions='controlAction')
>
> > This looks fishy. Why do you pass strings as control_options and
> > control_actions? And how do you invoke the form in the template, so far
> > I've not seen that.
>
> > Diez
>
> Hi Diez,
>
> This is the applicationControl.html template.
>
> ============
> <body>
>
>   <div id="getting_started">
>     <h2>The following allows you to start and stop Component
> Applications</h2>
>
>     <div py:replace="tmpl_context.form()">Input Form</div>
>
>   </div>
>
>   <p></p>
>   <p></p>
>   <p></p>
>   <p></p>
> </body>
>
> ==============
>
> control_options = is the start and stop select field.
>
> control_applications = is the list of applications.
>
> I am happy to share the whole lot of code with you, if you don't mind.

Updated as follows, based on Diez's instructions.

===============

Quote: Diez

"the problem is your usage of enumerate as option-list constructor.
This is a *generator* object. Thus after the initial display of the
form, it's exhausted.

I didn't notice that before, even though your shown code-samples in
the ML had that error. I guess that's because your code is pretty
convoluted - mixing form-declaration & creation of these lists into
the class-scope is a bit on the wierd side IMHO.

All you need to do is to wrap the generator into a list:"

===============

class applicationControlForm(TableForm):

    class fields(WidgetsList):
        installDict = getExecutables()
        applicationList = []
        hover_help = True
        for each in installDict:
            if each == "DMT" :
                pass
            else :
                applicationList.append(each)
        controlApplicationOptions = list(enumerate((applicationList)))
        controlApplication = SingleSelectField('Application',
options=controlApplicationOptions, \
                                               help_text = 'Please
select the Application to control.')
        controlActionOptions = list(enumerate(('start', 'stop')))
        controlAction = SingleSelectField
(options=controlActionOptions)
        submit_text = 'Save Movie'


create_applicationControlForm = applicationControlForm
("create_applicationControlForm", action='executeForm')


===========

Thank you so much, I really appreciate the help.

--

You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.


Reply via email to