First: documentation http://turbogears.org/2.1/docs/main/Controllers.html#subcontrollers-and-the-url-hierarchy
"Unlike turbogears 1, going to http://localhost:8080/movie will not redirect you to http://localhost:8080/movie/list." Can anyone try this? For me, it definitely redirects. Now about whether it makes sense. The docs say: "This is due to some interesting bit about the way WSGI works. But it’s also the right thing to do from the perspective of URL joins. Because you didn’t have a trailing slash, there’s no way to know you meant to be in the movie directory, so redirection to relative URLs will be based on the last / in the URL. In this case the root of the site." 1. What "interesting bit" about WSGI is referred to? 2. "movie _directory_"? What if I'm not dealing with file, but with REST structures (which Turbogears encourages; see also my example below) 3. The last part is clear, browsers do that. Let's assume we have some RESTish structure like mywebsite/users (gives a list of users) mywebsite/users/3 (gives details about user no 3) mywebsite/users/3/friends (gives a list of the friends of that user) a) Do you also think that the file/directory analogy does not completely work anymore? What is the user users/3? A file? Sensible in some way, but users/3/friends makes that impossible. So there is no easy rule => we should try to make it as sensible as possible. b) Assume we at mywebsite/users and we want to link to some user- specific resource wich is in users/script.js. If we are at mywebsite/ users and use <script src="script.js">, it does not work, because that (of course) resolves to mywebsite/script.js. If you open the page via mywebsite/users, it works. If you open it via mywebsite/users/index, it works, although that is semantically exactly mywebsite/users (implicit index). The web frameworks propose different solutions here: - Turbogears says "Which provides the redirect method with an absolute path, and takes you exactly where you wanted to go, no matter where you came from." (from the docs linked above) which means "use absolute urls". But this can be nasty. The docs doin "redirect('/movie/list/')" is especially annoying as it hardcodes the "movie" part just because MovieController is mounted as "movie" in RootController. This is does not look like TG as it is not reusable code at all and in addition, it is error-prone if somebody mounts it at "films". We could also use a sensible way to calculate the absolute path to the script, but this means we must use dynamic stuff everywhere which might be a bad idea in some cases; relative URLs are a good way to keep things modular and do not need dynamics. - Django just appends a / wherever it can. I'm not sure it is not only aesthetics, but "mysite/users/3/" or even "mywebsite/login/?next=" do not look correct in my view. c) In some other (Pylons or TG) docs it is said: "A controller is like a directory/ and a controller method is like a file" which seems pretty sensible. d) If you are inside a Controller() with def index and def login and you use url('login') or redirect('login') in index() you would expect that it leads to your login def instead of somewhere above your controller - this fits to c). I think the solution is to append a trailing slash exactly when an implicit index is called. This makes sense because - When an implicit index is called, it _means_ that what you surf to is a directory. - It fits b) because it solves the paradox that it works for mywebsite/ users/index but not for mywebsite/users although they are the same because of the implicit index - It does not violate c) - It makes d) do what you expect it to do. In implementation, it would be handling an implicit index as if it had @with_trailing_slash. What do you think, do you agree? -- You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears?hl=en.

