I am just trying to understand the limits of the framework... I just wonder if it is possible to have some controller functions written somewhere other than in files in the app/controllers/ folder, yet still have them be exposed via a file in controllers.
Example: I have the following file structure: 1. app/controller/lib/sayhi.py <- has code: def sayhi(): return dict (message="Hello") 2. app/controller/lib/__init__.py <- empty file (maybe don't even have it there if not necessary to make this work) 3. app/controller/default.py <- has code: def index(): return dict() and some code to expose sayhi() in app/controllers/lib/sayhi.py 4. app/view/index.html <- has code: <html><body><a href="{{=URL (r=request, f=sayhi)}}">Say hi</a></body></html> 5. app/view/sayhi.html <- has code: <html><body>{{=message}}</body></ html> On Apr 5, 2:24 pm, waTR <roman.goldm...@gmail.com> wrote: > Not necessarily. I am just wondering if it is possible to have a > controller within a sub-folder of the "Controllers" folder. like "app/ > Controllers/user/register/newuser" where "user" is a sub folder, and > "register" is the controller. > > I can't come up with any specific example of why I need this, though I > still want to know if it's possible. Right now I am going to achieve > the same intent just by importing the functions from the "register" > controller into another controller in the "Controllers" folder. I > think that should be the way to do it anyway, as the current web2py > app/controller/function/arg setup is clear, simple, and very workable. > > On Apr 5, 2:11 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > Just so that I inderstand. Instead of having controller files (like > > default.py), you want to have controller folders, so that each action > > is its own file? > > > Massimo > > > On Apr 5, 4:04 pm, waTR <roman.goldm...@gmail.com> wrote: > > > > Well, it is just a question as to whether this is possible. I was > > > hoping to organize my project files via folders rather than simply > > > controllers/functions. However, I realized I can achieve the same > > > general effect via linking functions held within controller/sub-folder/ > > > functions by importing them in controller/linker-controller. > > > > However, I was curious as it doesn't seem sub-folders are possible so > > > far, and I was just wondering if someone was willing to play the > > > devils advocate and just ask the question. I find it rather more > > > productive to ask the question and ensure there is definetly a way to > > > achieve the INTENT of project file organization with web2py via > > > linking (which is actually completely fine). > > > > I just thought it might be interesting to have a controller and sub- > > > folder tree that mirrors a website folder tree. I am just really not a > > > fan of having 100 files in a single directory, and was hoping to keep > > > it down to like 10 or less files per folder. > > > > Any suggestions as to some good practice for file management in web2py > > > (file/folder make-up/organization)? > > > > My idea right now (based on what web2py can do), is have linker > > > controllers under the "Controllers" folder, and have a bunch of sub- > > > folders in the "Controllers" folder which will contain all the actual > > > functions and business-logic. > > > > Any other ideas/suggestions? > > > > On Apr 5, 5:35 am, Vidul Petrov <vidul.r...@gmail.com> wrote: > > > > > > it is such an important feature for organizing a large project... > > > > > Because? > > > > > The controller itself provides a namespace, not the filesystem. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" 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 -~----------~----~----~----~------~----~------~--~---