Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6229961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:39:42+00:00 2026-05-24T09:39:42+00:00

I just found web2py a couple days ago, and have been reading the documentation

  • 0

I just found web2py a couple days ago, and have been reading the documentation and through the source of a few example applications. I want to start programming more in Python. It seems that my take on MVC is a little skewed from theirs [web2py community].

After learning and working with PHP (and the Kohana framework), I’m used to the thin controller – fat model principle, where all business logic is placed in the model and the controller does nothing more than delegate what methods to perform on the model, and then passes data onto the view for rendering. However, it seems that 99% of the applications I’ve seen for web2py have fat controllers (putting all business logic in the actions), and the models are nothing more than table/constraint definitions.

I’m pretty well set on my view of a model, and I would rather put the business logic in the models (for re-usability and DRY code) but I haven’t seen any code online that does this, although, to be fair, I haven’t found an ample amount of applications. Can somebody point me in the right direction.

To be clear, I would like to make my models actual classes and encapsulate all business logic and database interactions into explicit methods. Something along the lines of…

class Article(object):
    def get_article(self, id):
        # Retrieve article by id, using db instance
        pass
    def get_latest_articles(self, limit):
        # Retrieve latest articles
        pass
    def get_hot_articles(self, limit):
        # Retrieve hot articles, based on algorithm for "hot"
        pass
    def create_article(self, data):
        # Insert article
        pass
    def define_tables(self):
        # Define schema the web2py way
        pass

I haven’t found the right way to do this.

I’m not very well rehearsed on web2py, but I know there are a lot of features. The DAL, for instance, seems to be a very powerful feature which is tightly integrated with other helpers. I wonder if splitting my business logic as stated above would limit any of these features?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:39:44+00:00Added an answer on May 24, 2026 at 9:39 am

    I think part of the difference is that web2py uses a DAL (database abstraction layer) rather than an ORM. You might find this explanation helpful. As it points out, in some cases, computed fields or virtual fields may do what you want. Also, some of the methods defined in your example class would be quite simple DAL statements and would probably not be worth writing methods for.

    Of course, if you want, you can define classes and functions in your models (or modules) and simply call them from your controllers — whatever works best for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just found this bit, while reading eclipse JDT 's documentation: IMethodBinding.getParameterTypes() : . .
I have just found RowSets for database querying with JDBC. They are stateless and
Update : I just found this documentation page . Wish there was a link
We have just found we are getting framing errors (as reported by the WCF
I had been using using PIL but I just found out that it doesn't
I just found out how to have help open and the code editor open
Just found the following in the Java EE Documentation for javax.faces.component.UISelectMany : Obtain the
I just found in the documentation that FloatToStr and DateToStr are not thread-safe in
I have MacPorts and CPAN installed and I've only just found out that it's
I have read chapter 4 of SICP, and just found that the first section

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.