I can see the logic for how a SmartForm would work, and perhaps as Yarko
suggests I need to sit down and do some flow charts so we can all get an
idea of what I'm thinking, and how this would actually benefit. Lots of
things would benefit from this, from the ability to create better custom
widgets, to assigning custom validation/signals, allowing views that can be
easy, yet powerful and customizable.

Massimo it would help if you could explain exactly how helpers work, and how
they validate themselves, and how form wraps around helpers, and how sqlform
wraps around form... I would really appreciate it.

Correct me if I'm wrong.

It seems that we have Validator classes, and these classes of course,
validate the data. Helper classes can have validators, that when the helper
asks, will validate if the helper has the correct value or not. Helpers can
have children, which consists of other helpers, these are called
components?. Now form is just a helper, that consists of input/textarea/etc
helpers. When form is asked to validate (form.accepts) it recursively
iterates through all of its children helpers, asking them to validate. If
one fails validation, it adds the error to form.errors and form.accepts
returns false. Now sqlform wraps around this, allowing you to specify
database fields, it takes these fields and creates the corresponding helpers
based on data type, or widget if there is one (a widget is just another set
of helpers). sqlform then takes these generated helpers (widgets) and
creates a FORM with them (actually, SQLFORM is a FORM). when sqlform is
asked to validate, it passes the validation on to its FORM part, SQLFORM
then takes the data, and puts it in its correct python type, based on the
data type, and if the form succeeded validation, performs the database
input/output. SQLFORM.factory just creates a DAL reference that does not
link to a database, and passes this along to SQLFORM. When displaying the
form in a view, it just calls its xml() method, which recursively iterates
through all components, asking them to render themselves, which this happens
in class DIV. I think that covers that crazy train :)

My problem is I don't see a way of creating a smartform, that allows the
separation of logic that will provide the custom interface we all desire,
with using helpers. And the big problem is, since web2py is coupled, I don't
think the this can be solved without the use of helpers either. Not without
having to rewrite a-lot of functionality that already exists, which I
wouldn't want to do. I am starting to think this isn't going to be as simple
as adding a new class, and might require refactoring of how validation is
handled all together, but I'm not sure. i need to sleep on it some more.
What do yall think?

-Thadeus




On Sun, Dec 20, 2009 at 1:40 AM, hamdy.a.farag <hamdy.a.fa...@inbox.com>wrote:

>
> well,
>
> suppose you've a form for registeration that's related to auth_user
> table
> Now you can register new users and no problem
>
> suppose after a while you need a page where manager can add special
> users to them , [firs_name, last_name , ......] but in the
> registration form you need a new field to be added ,
> let's say the new field is a combo box that selects some thing from
> another table .
> This 's ok if I'm going to use SQLFORM.factory
>
> what if ....
>
> I already have the Form that adds this special user that satisfied me
> in the past , now I need to change it to suit my needs
> so this needs to refactor my code using SQLFORM.factory
> as you can see refactoring my code can be painful, and I'm always
> refactoring my code
> Now I can take  a decision to simply use just SQLFORM.factory from the
> beginning if my software changes frequently and this's not easy as
> using SQLFORM
>
> my other decision is to add the table manually to the form
> (form.insert.....) but this has a problem that this field can not be
> validated upon accepting the form
>
> Now we need SQLFORM to be more customizable, meaning that I can add to
> it a field from another table, another field that doesn't belong to
> any table and that can be validated upon accepting the form
>
>  - may be we need a new SMARTFORM - as you've suggested -
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to
> web2py+unsubscr...@googlegroups.com<web2py%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/web2py?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to