Sophie -

It may help to think about the dataflow in web2py (you can follow the
diagram on P. 6 of the manual found at
http://www.web2py.com/examples/default/docs):

[]  A request comes into the server, and gets passed to web2py:main();
[]  main validates the path/url, and then selects the application on the
web2py server to run, and finds the controller
[]  all the model structures for that application are setup;  if that
implies creation or altering the actual tables, that happens next;
   --->  note: this is the Python interface to the actual database table, so
it can legitimately define the subset of the table which web2py app will
use;
[]  Now that the environment (e.g. connection, table structres) are setup
for this application/request, the controller is called;
[]  The controller may fetch data, pre-load data from the db, etc. as
needed, (DAL == Data Abstraction Layer), and then "return" a dictionary of
values to the view  ( view_named_variable = controller_variable) --- main()
will pass the call to the view;
[]  The view (and whatever "pure python" code it contains) is rendered, and
returned to the client (response);

If there are forms, the controller is called with request args (named,
dictionary) and/or vars (positional) set, and validation and data commit
happens transparently (by default).   See section 4.2 (p.96) in the manual
(online) for more details of URL mapping.

You can see the variables passed / available to the controller by glancing
at:
http://www.web2py.com/examples/simple_examples/hello6
or
http://www.web2py.com/examples/simple_examples/status

This is a bit to digest, but hope it is helpful.

Regards,
- Yarko

On Wed, Sep 30, 2009 at 12:00 PM, 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