And I think this has more to do with "concept" of what constitutes a layer than anything else;
If you think about network boundaries, then the three layers can be referred to as: - presentation; - business logic; - persistence layer; So - with web apps / thin client (ignoring Flex as a rich client component for the moment, and just focusing on core web2py), Since web2py doesn't have an "ORM" - the DAL is "like" that (even though it's abstraction is closer to the data-layer, it is a business logic thing). The views setup the presentation, and these are all in the views folders (and translation of variables is done by the templating language - which in web2py's case is just "plain" Python, adapted for mixing into html). The _content_ of forms is still business logic activity, and committing transactions is usually done "for you" (the data layer is tucked away in web2py core, and in the database libraries for the particular database connection). So, you could think of web2py as focusing on default behaviors, and largely leaving mostly business logic for you to focus on (e.g. not a lot of setup). On Wed, Sep 30, 2009 at 5:05 PM, mdipierro <mdipie...@cs.depaul.edu> wrote: > > I used google translate and I am not sure I understand everything. > > Normally you have the 3 layers: mode+view+controller but they do not > have to map 1-1-1. > You can have 10-1-1, 1-10-10,1-10-1 etc. > > For exanple you can have one controller action display results from > different tables depending on a parameter and use the same view for > all of them. > > def list_and_create(): > table=db[request.args(0)] > if not table: raise HTTP(404) > form=crud.create(table) > rows=db().select(table.ALL) > response.view='default/list_and_create.html' # optional but here > to explain > return dict(form=form,rows=rows) > > then you can call: > > http://../list_and_create/auth_user > http://../list_and_create/auth_group > http://../list_and_create/anyoneofmytables > > Hope this is helpful. > > Massimo > > On Sep 30, 2:49 pm, Sophie <kfarron...@gmail.com> wrote: > > 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 -~----------~----~----~----~------~----~------~--~---