No te preocupes yo hablo español (idioma natal seguro mi inglés
también es malo XD), lo que me preocupa al hacer esto es no obedecer
las 3 capas. Según lo que siempre he visto es que la vista le pasa
datos al controlador y de ahi la pasas al modelo. Lo que he visto en
web2py es que el controlador tiene los label y en el controlador creo
una forma, entonces no necesito mucho de la vista, o si? Yo hice este
modelo hace un rato y me funcionó el problema de esta solución es que
tengo que hacer hacer una vista por cada tabla en la base de datos,
como en java. Estaba pensando hacer un menú, y de ahí sacar el nombre
de la tabla, dependiendo de esto mostrar los campos de la tabla que
sean necesarios. Claro es un montón pero como me obligan a usar las 3
capas, creo que no hay de otra, o la solución que me propones no viola
esta regla.

On 30 sep, 12:00, ProfessionalIT <lsever...@gmail.com> wrote:
> Sophie,
>    I'm a Java programmer too, then I can help you !.
>
>    First,
>
>        In the file db.py you map your table, in this case the table
> that the class StoreBean map. In this class(StoreBean) you have the
> fields(properties) and the getters and setters to this fields.
>        In Web2Py you don't need this, only define the table in db.py,
> follow this sintaxe:
>
>        For example:
>
>        db.define_table('pampa_tabelapreco',
>         Field('categoria',db.pampa_categoriacliente),
>         Field('produto',db.pampa_produto),
>         Field('preco','double', default='0.00'))
>        db.pampa_tabelapreco.categoria.requires=IS_IN_DB(db,
> 'pampa_categoriacliente.id', 'pampa_categoriacliente.nome') /* This
> map a relation */
> db.pampa_tabelapreco.produto.requires=IS_IN_DB(db, 'pampa_produto.id',
> 'pampa_produto.nome_compra') /* This map a relation */
> db.pampa_tabelapreco.categoria.label = T('Categoria de Cliente') //
> This map the Labels to the Form.
> db.pampa_tabelapreco.produto.label = T('Produto') // This map the
> Labels to the Form.
> db.pampa_tabelapreco.preco.label = T('Preço') // This map the Labels
> to the Form.
>
>   Second,
>
>       In the Java Controller, you get the parameters of the request,
> put this values in the bean and pass this bean to a DAO object.
>       In Web2Py you don't need this !. In the controller (default.py
> for example) you create a function that create a form of a table,
> validate this form and save the data, all-in-one (yes !, Web2Py is a
> excelent tool!), follow this sintaxe in your controller:
>
>        def tabela_preco():
>            ### create an insert form from the table
>            form=SQLFORM(db.pampa_tabelapreco)
>            ### if form is correct, perform the insert
>            if form.accepts(request.vars,session):
>               response.flash='new record inserted'
>            return dict(form=form)
>
>     Now, when you access this controller, the Web2Py generate a
> Form !, try:
>
>      http://127.0.0.1:8000/yourapp/defaul/tabela_preco
>
>      This show the form with the fields of the table in a page !
>
>      ps: Sorry by my terrible english ! .
>
>  -- Leandro.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@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