On Thursday, January 27, 2011 11:00:45 AM UTC-5, viniciusban wrote: 
>
> On Thu, Jan 27, 2011 at 3:27 AM, Bruno Rocha <rocha...@gmail.com> wrote:
> > Thinking a bit more, taking the Vinicius comment and some examples of
> > another O.O frameworks.
> > I was wondering about...
> > #2
> > auth.settings.formstyle = 'divs'
> > form = auth()
> > print form #  return the HTML with divs 
>
> OK, but formstyle isn't related to auth in anyway, but it is to form, 
> right?
> If auth wouldn't be showed (rendered) as a form, this property never
> needed to be used.
>
Auth does a number of things, one of which is to generate various forms 
related to authentication (e.g., registration, login, recover password, 
etc.), so it seems relevant for it to have settings telling it how to render 
the forms it generates.

> > ...
> > form.formstyle = 'divs' # sets the self.formstyle to 'divs'
> > and immediately raises a redraw method
> > #alternatively call explicitly the form.redraw() method
> > print form # should now return HTML with 'divs'
> >
> > I think Vinicius are talking about the case #3, which I think it is 
> possible
> > to implement, but I don't know the caveats, 
>
> Yes Bruno. You catched my mind. 
>
> Actually, formstyle='divs' is a SQLFORM form property. It is the way
> print will show the generated HTML for this form instance.
>
When you create a SQLFORM form, it actually generates the HTML for the form, 
which is then passed to the view. There isn't a separate HTML-generation 
step at "print" time. So any properties that affect the HTML have to be set 
before the form is created (so, 'formstyle' is passed as an argument to the 
SQLFORM __init__ method).

> So, conceptually it is a form property. 
>
> Your 3rd example show an intuitive method do implement this feature. 
>
> I didn't have time to see the source code yet (I plan to do this
> tonight), but I see no reason to generate HTML code before the print
> call.
>
At what point would you prefer to generate the HTML? Would you prefer an 
explicit extra step to call a render method on the form sometime after it is 
initially created (either before or after passing it to the view)? What are 
the benefits of that approach?
 
Best,
Anthony

Reply via email to