So we have a legacy database that has a suboptimal structure, but we
cannot change it right now.
What we want is to create a business layer in-between web2py and this
database so that web2py thinks it is using a much better database
structure in order for the development in web2py to be what we want
the end result to be when the database is finally restructured.
By defining a sort of virtual model in web2py (that is more how we
want the final database to look like) we can use the benefit of
creating forms very easily in web2py, and then just forward the
results to the business layer and let it take care of the real
database.
But problems arise when the web2py forms etc. assumes that the model
really has a physical database behind it, for instance the CRUD forms
where the crud.update gathers info on the record from database and
puts it in the form automatically. We want this of course but the
web2py model has no real database.
One way of doing this would be to use SQLFORM.factory and manually
inserting all the values into the inputs like so:
inputs = form.elements('input')
inputs[0]['_value'] = user.name
inputs[1]['_value'] = user.email
...
but this sort of manual work seems unnecessary for big forms
Another problem I had with CRUD forms in my case is that I really want
to make the if .accepts() call myself so that I can then call the
business layer with the database related stuff, but it seems the CRUD
forms do this call automatically?
In the case of SQLFORM.factory forms I can make the .accepts myself
Do any of you have experience in these kinds of problems? Is there a
painless way to do it?
I would be most thankful for any tips regarding this