I think that might solve it. Though, are there any plans to make it a
little easier? Like say by making a expose(mymodule) or something?
Nothing serious, though. The method you describe is sufficient to
achieve the desired results, and listing one-liner definition links
are no big deal.

Cheers




On Apr 5, 9:35 pm, mdipierro <[email protected]> wrote:
> That is a very old thread about T2.
>
> As in any Python program/framework you can define functions in modules
> and create any directory structure you want.
> In order to expose a function from a module as an action you still
> need one line in the controller:
>
> #in default.py
> import applications.myapp.modules.sayhi as mymodule
> def sayhi(): return mymodule.sayhi(....)
>
> You will have to pass globals() or request, response, session, cache
> and T to the function in the module.
>
> Massimo
>
> On Apr 5, 6:29 pm, waTR <[email protected]> wrote:
>
> > Hang on! This has already been proposed!!  Has it been added yet? How
> > was it resolved?
>
> > Someone already proposed this, and it seems to have been 
> > accepted:http://groups.google.com/group/web2py/browse_thread/thread/1bc0711d6d...
>
> > This is EXACTLY what I am looking for. My web-app is a web-based
> > accounting program, and I will have over 100 functions and I really
> > want to keep the controllers folder organized and minimal and not have
> > 100 .py files with 40 long functions in each file. I NEED a directory
> > structure. However, I also don't want to screw with web2py's
> > simplicity re controllers folder and url path (app/controller/function/
> > arg -- LOVE IT). Not having a proper source-code directory structure
> > would totally screw-up my source-code management logic for this app.
>
> > I really don't want to have all my functions defined in a long list of
> > files under the same directory.
>
> > Any status re the proposal in the post at this 
> > URL?http://groups.google.com/group/web2py/browse_thread/thread/1bc0711d6d...
>
> > On Apr 5, 4:15 pm, waTR <[email protected]> wrote:
>
> > > 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to