Let me disagree with Leonel.
In MVC, business logic should be handled by model and application logic
by controller, this is also called "fat models and thin controllers", by
example, a model should know by itself how to calculate his own {put
here: price, length, age, pretty hard calculation using my super
algorithm}, and the controller should only worry about giving to the
model the data he needs.
In fact, a MVC purist will say that code like sqlform.factory does not
belong to controller (this is something that I partially disagree when
we are using frameworks like web2py).
Greetings.
El 09/02/17 a las 18:01, Leonel Câmara escribió:
Yes they should be done in the controller, web2py mostly follows the
MVC architecture so most of the business logic is supposed to be in
the controller. Notice that if you put the calculations in the view
for instance "product_calc.html" then you would not have the result
available in "product_calc.pdf" or "product_calc.json" or some other
view that you could do for this logic. That said, it's kind of a
matter of taste, for instance, you may feel strongly that a given
calculation is only useful for a given view so you can start by
putting it there and later move it to the controller if you find out
that you were wrong and you will need it elsewhere.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google
Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to web2py+unsubscr...@googlegroups.com
<mailto:web2py+unsubscr...@googlegroups.com>.
For more options, visit *MailScanner ha detectado un intento de fraude
en la siguiente p�gina web "groups.google.com". /No/ conf�e en esta
p�gina web:* https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.