Issue Details (XML | Word | Printable)

Key: GRAILS-1243
Type: Sub-task Sub-task
Status: Open Open
Priority: Minor Minor
Assignee: Graeme Rocher
Reporter: Victor Volle
Votes: 17
Watchers: 13
Operations

If you were logged in you would be able to see more operations.
Grails
GRAILS-3406

Improve support for Controllers to be placed in sub-folders/packages.

Created: 08/Jun/07 11:37 AM   Updated: Monday 08:40 AM
Component/s: Controllers
Affects Version/s: 0.3, 0.4
Fix Version/s: 1.2-M2

Time Tracking:
Not Specified

Issue Links:
Related


 Description  « Hide
Add support for placing controllers in sub-folders/packages within the controllers folder so you can keep related controllers together, create more structured urls and make path based url security easier?

For example:

\grails-app\controllers\SiteController.groovy -> http://localhost:8080/sample/site
\grails-app\controllers\admin\UserController.groovy -> http://localhost:8080/sample/admin/user
\grails-app\controllers\admin\RoleController.groovy -> http://localhost:8080/sample/admin/role

And views would obviously have to follow the package structure of their controller:

\grails-app\views\admin\user\show.gsp



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Victor Volle added a comment - 08/Jun/07 11:38 AM
I have created this clone of GRAILS-221, because:

This improvement as described in GRAILS-221 is only half of the enhancement, and its not leading anywhere.
A package is a namespace and not only a name.
The reason that controllers, domain classes should be in packages is exactly that multiple teams would be able to work in parallel if each team has its own package, and must not consider name clashes.


Graeme Rocher added a comment - 14/Jun/07 05:37 AM
We're unlikely to support this for multiple reasons. First of all if you want those kinds of url patterns then you use the URL mappings feature http://grails.org/URL+mapping

Second having name spaces at the URL level has wider implications for other parts of the system. Such as scaffolding. For example if you have a domain class foo.bar.Hello what table does it now map to? Is it foo_bar_hello by default?

Back to URL mapping now. How does one reference a controller in a package when doing url mapping? It starts to get messy and ugly. I'm strongly of the belief that the current solution is as far as we should take it. As for multiple teams working, i've participated in many multi-team projects and never heard of one that involves no communication between teams


Victor Volle added a comment - 15/Jun/07 09:39 AM
Hi

I understand that you want to keep Grails as simple as possible. So if you do not support this, it will just narrow down the number of projects where I would consider using Grails, but perhaps this is even neccesary (to keep Grails simple). But ...

1) URL: I do not really understand the issue here. Yes it has implications, but what are the problems.

2) Domain class => table name: Why not map foo.bar.Hello to foo_bar_Hello as the default case (as long as I can override), you do not have to use mutliple packages, Maybe all domain classes in a package share some common configurable prefix? Maybe only the last package name shall be used as part of the table name – whatever.

3) URL (again): I have not looked too thoroughly into the URL mapping stuff, so I refrain here

4) Multiple teams:
no communication between teams: what a horror.
communication that ain't necessary: what a waste of time ... that's why I prefer to have name spaces that give teams their own "fiefdom"

Victor


Marc Palmer added a comment - 15/Jun/07 10:16 AM
I see exactly why this is a problem for the implementation. There are numerous reasons why the "name" string used internally for a class does not allow dots or similar, and that these are used in many ways to implement conventions.

I do not think it is a big problem for grails to insist on unique class names in you grails class graph.


Simon Briman added a comment - 06/Jul/08 02:31 PM
1. URL: Imagine that you have an app where user's front-end and admin's back-end differ so that they're better server by different set of controllers and views. Currently what we do? We create FooController and AdminFooController, create views under adminFoo dir and add a URL mapping "/admin/foo/$action?/$id?" { controller = "adminFoo" }. Now "rinse and repeat" for bar, baz, etc... Ugly as my life.
If we had packages we could create FooController and admin.FooController, create views under admin/foo and no URL mappings at all. Just cleaner.

2. Domain class => table name: It feels quite organic to me to map foo.bar.Hello to foo_bar.hello by default where foo_bar is a DB schema name.

3. Rails has it. )))


Graeme Rocher added a comment - 10/Feb/09 07:28 AM
Moving non-critical issues that aren't going to make it into 1.1 to 1.2