Splitting long controller file

27 views
Skip to first unread message

clara

unread,
Aug 21, 2019, 4:45:38 PM8/21/19
to web2py-users
Hello,

Maybe this may sound trivial (bear with me, please) but here is my question: I have a long controller module that I would want to split up or make more manageable . Most of the functions in this controllers are controller functions called from the frontend. 

Now, I guess I could refactor the module and have some support functions and create a new module in the "modules" folder. This has brought me problems in windows environment, so I would try to avoid it. 

I could create other controller modules and move some controller functions to them, but then I would need to update the frontend ajax calls. 

Any ideas?

Thanks in advance.

Tim Nyborg

unread,
Aug 22, 2019, 5:38:42 AM8/22/19
to web...@googlegroups.com
Admittedly, splitting a lot of the functions into a module would be the best solution.

We recently had the same challenge, and moved a bunch of functions from our default controller into their own controllers, without having to change frontend calls.  This only worked because the functions were in the default controller, which was hidden in URLs by default. Function "whatever" in default.py became function "index" in whatever.py.  so any call to website.com/whatever still worked

Alternately, you can move the support functions into a model file(s) that only gets loaded for that controller.
Reply all
Reply to author
Forward
0 new messages