Re: [web2py] Re: new URL router use cases

2011-03-24 Thread pbreit
I think I'm in agreement. App-specific routing should be controlled at the app level. I was just saying that it might be tricky to figure out how to set up the default file structure and routes to both work and handle future updates.

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Martín Mulone
Sorry perhaps I don't express myself correctly, I'm not saying this is a bug or I can't do with the current way. I'm only saying that I think better if there are something like that in app level. It's an idea. Main routes.py to control things up to the application, and the rest by the application.

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread pbreit
+1 for a move towards routes default "on" and primarily controlled at the app level. But I do recognize there is an issue about what file should come in the main distribution and how to avoid it being overwritten with updates. The default files could duplicate the current default functionality f

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Tom Atkins
Thanks Anthony - you're right and I do know this - just wrote the wrong thing in my previous post - I meant to say 'change to pattern-based'... make me wonder what other stupid mistakes I'm making... but double checked and I think I have everything correct and as suggested by Massimo. On 24 March

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Anthony
Tom, you cannot mix usage of the parameter-based and pattern-based routing systems, even if one is in the global routes.py and one is in an app-specific routes.py. You have to pick one system or the other, for now anyway. Anthony On Thursday, March 24, 2011 1:59:33 PM UTC-4, Tom A wrote: > T

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Tom Atkins
Thanks for this suggestion Massimo - it's the closest to what I'm looking for. I've tried to get it to work but no joy. I've changed my global routes.py to use parameter based routing sand put the first part of your code in the application specific routes.py. I've then put the 2nd part of your c

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Jonathan Lundell
On Mar 24, 2011, at 10:35 AM, Anthony wrote: > On Thursday, March 24, 2011 12:51:56 PM UTC-4, Martin.Mulone wrote: > Yes but not in the application folder. The importance is to be distributed > with the application. I think you two might be talking at cross purposes here. It goes in applications

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Anthony
On Thursday, March 24, 2011 12:51:56 PM UTC-4, Martin.Mulone wrote: > > Yes but not in the application folder. The importance is to be distributed > with the application. With both systesms, you can put a routes.py file in the application folder, but at least with the older system, for that t

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Jonathan Lundell
On Mar 24, 2011, at 9:57 AM, Martín Mulone wrote: > For example I have a blog application with this url > > http://www.mysite.com/blog/default/post/2010/10/10/my-article > > I can short to this: > > http://www.mysite.com/blog/2010/10/10/my-article > > with this one route: > > (r'.*:/blog/(?P(1

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Martín Mulone
For example I have a blog application with this url http://www.mysite.com/blog/default/post/2010/10/10/my-article I can short to this: http://www.mysite.com/blog/2010/10/10/my-article with this one route: (r'.*:/blog/(?P(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01]).*)$',r'/blo

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Tom Atkins
The problem for me is not being able to mix the new parameter-based routing with the pattern-based system (my regex skills are not good enough to make the patten system do what I want) . Is it possible to have parameter system in the global routes.py and then pattern system in the app-specific

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Martín Mulone
Yes but not in the application folder. The importance is to be distributed with the application. 2011/3/24 Anthony > I believe this is already possible, no? > > The book describes app-specific routing for the old system: > http://web2py.com/book/default/chapter/04#Pattern-Based-System > > And f

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Jonathan Lundell
On Mar 24, 2011, at 8:04 AM, VP wrote: > > Noticing the version of web2py keeps interestingly increasing to 2.0, > I think this is something Massimo might want to spend sometime > thinking about. > > As I understand it, because of "exec", controllers are called *after* > the request arrives. Thi

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Anthony
I believe this is already possible, no? The book describes app-specific routing for the old system: http://web2py.com/book/default/chapter/04#Pattern-Based-System And for the new system, the router.example.py file ( http://code.google.com/p/web2py/source/browse/router.example.py) mentions yo

[web2py] Re: new URL router use cases

2011-03-24 Thread Anthony
On Thursday, March 24, 2011 11:04:39 AM UTC-4, VP wrote: > > Noticing the version of web2py keeps interestingly increasing to 2.0, > I think this is something Massimo might want to spend sometime > thinking about. I don't think the xx part of 1.xx.y is to be interpreted as a decimal with a

Re: [web2py] Re: new URL router use cases

2011-03-24 Thread Martín Mulone
I really want to see routes in the application folder. Routes in the past was hard to follow, now I think the work of Johnatan make it more easy. But when you have many applications, the routes for all is a bit messy. I don't know if this can be done: For example a simple case: Main routes.py: --

[web2py] Re: new URL router use cases

2011-03-24 Thread VP
Noticing the version of web2py keeps interestingly increasing to 2.0, I think this is something Massimo might want to spend sometime thinking about. As I understand it, because of "exec", controllers are called *after* the request arrives. This allows web2py to do a few interesting things that ot

[web2py] Re: new URL router use cases

2011-03-24 Thread VP
Can't this be done in web2py with something like this? assert(request.args(1) == 'users') yoursitename = request.args(0) On Mar 23, 8:31 am, Anthony wrote: > Massimo, I think Tom was referring to Flask's ability to include an arg at > an arbitrary place in the URL path (e.g., '//users'), not th

[web2py] Re: new URL router use cases

2011-03-23 Thread Massimo Di Pierro
yes. For example: routes_in = [ ('/$yoursitename/users','/init/default/users/$yoursitename'), ] the optionally @request.restful() def users(): def GET(yoursitename): return dict(message='your site name is: '+yoursitename) return locals() On Mar 23, 2011, at 8:31 AM

[web2py] Re: new URL router use cases

2011-03-23 Thread Anthony
Massimo, I think Tom was referring to Flask's ability to include an arg at an arbitrary place in the URL path (e.g., '//users'), not the ability to specify the routes via decorators. I think the former *can* be achieved in web2py using the pattern-based rewrite system, right? Anthony On Wedne

[web2py] Re: new URL router use cases

2011-03-23 Thread Massimo Di Pierro
This is not an option in web2py because the controller is executed after the requests arrives not imported before (as in Flask). Anyway, that works better for simple apps but becomes a mess if you have many functions because the routing info is scattered all over the place. Moreover - when it comes

Re: [web2py] Re: new URL router use cases

2011-03-22 Thread Indra Gunawan
Warning, TMIIW; Those technique require to load all exposed functions, it won't act as lazy load (load on demand). Thats I've read on Flask book :) On 22 March 2011 23:06, Tom Atkins wrote: > It uses Werkzeug - full details here: > > http://werkzeug.pocoo.org/docs/routing/ > > > On 22 March 201

Re: [web2py] Re: new URL router use cases

2011-03-22 Thread Tom Atkins
It uses Werkzeug - full details here: http://werkzeug.pocoo.org/docs/routing/ On 22 March 2011 14:49, Jonathan Lundell wrote: > > Maybe so. Is there a formal definition of how Flask's routing works? All I > could find was a rather brief overview at the quickstart link. > >

Re: [web2py] Re: new URL router use cases

2011-03-22 Thread Jonathan Lundell
On Mar 22, 2011, at 1:14 AM, Tom Atkins wrote: > sorry - should have been: > > @app.route('//users') > ... def editusers(yoursitename): pass > > print url_for('editusers', yoursitename='Supersite') > > gives: > > /Supersite/users Maybe so. Is there a formal definition of how Flask's routing

Re: [web2py] Re: new URL router use cases

2011-03-22 Thread Tom Atkins
sorry - should have been: @app.route('//users') ... def editusers(yoursitename): pass print url_for('editusers', yoursitename='Supersite') gives: /Supersite/users On 22 March 2011 08:13, Tom Atkins wrote: > I might be being naive here but in Flask I can do: > > @app.route('//users') > ... de

Re: [web2py] Re: new URL router use cases

2011-03-22 Thread Tom Atkins
I might be being naive here but in Flask I can do: @app.route('//users') ... def editusers(yoursitename): pass print url_for('editprofile', yoursitename='Supersite') gives: /Supersite/users On 22 March 2011 05:23, Jonathan Lundell wrote: > On Mar 21, 2011, at 7:44 PM, Indra Gunawan wrote:

Re: [web2py] Re: new URL router use cases

2011-03-21 Thread Jonathan Lundell
On Mar 21, 2011, at 7:44 PM, Indra Gunawan wrote: > Agree, Flask way looks more elegant (see Variable Rules). It could be nice if > this way also exists on Web2Py. > > On 22 March 2011 06:05, Tom Atkins wrote: > I was playing with Flask and I have to say its solution to routing is very > nice

Re: [web2py] Re: new URL router use cases

2011-03-21 Thread Indra Gunawan
Agree, Flask way looks more elegant (see Variable Rules). It could be nice if this way also exists on Web2Py. On 22 March 2011 06:05, Tom Atkins wrote: > I was playing with Flask and I have to say its solution to routing is very > nice: > > http://flask.pocoo.org/docs/quickstart/#routing > > The

Re: [web2py] Re: new URL router use cases

2011-03-21 Thread pbreit
Yeah, I suspect it can be done with routing. This might be a common use case (ex: Github, Bitbucket, Twitter) so wondering if it's worth making sure it's well-supported?

Re: [web2py] Re: new URL router use cases

2011-03-21 Thread Tom Atkins
Thanks Jonathan! What would be the mapping of, say, myapp.com/yoursitename/xyz? yoursitename would be the first arg I guess xyz would be the second arg - although it'd be handy if it could be a controller or function! Your suggestion solves my problem - I've just added: functions=['admin', 'ab

Re: [web2py] Re: new URL router use cases

2011-03-21 Thread Jonathan Lundell
On Mar 21, 2011, at 2:37 PM, Tom Atkins wrote: > I am designing an app with a URL structure like this: > > myapp.com/yoursitename > > 'yoursitename' is effectively an argument as there could be many sites and > users are allowed to create their own sites. But I'd like it to be 'top > level'. >

Re: [web2py] Re: new URL router use cases

2011-03-21 Thread Tom Atkins
Thanks for the reply - I've considered the subdomain option but don't want to use it in this case. This article: http://warpspire.com/posts/url-design/ was previously linked on the forum and summarises very well the reasons I'm keen to go for a URL structu

Re: [web2py] Re: new URL router use cases

2011-03-21 Thread David Warnock
Tom, I am designing an app with a URL structure like this: > > myapp.com/yoursitename > > 'yoursitename' is effectively an argument as there could be many sites and > users are allowed to create their own sites. But I'd like it to be 'top > level'. > An alternative might be to use subdomains eg

Re: [web2py] Re: new URL router use cases

2011-03-21 Thread Tom Atkins
Just to clarify - each 'yoursitename' is part of the same app - it could be 'youusername' or 'yourorganisation' depending on the app. e.g. see github's url structure: https://github.com/isotoma/ isotoma is the 'username' or 'y

[web2py] Re: new URL router use cases

2011-03-21 Thread VP
I think each "yoursitename" should be a different app. I think it's most efficient that way. On Mar 21, 4:37 pm, Tom Atkins wrote: > I am designing an app with a URL structure like this: > > myapp.com/yoursitename > > 'yoursitename' is effectively an argument as there could be many sites and >

Re: [web2py] Re: new URL router use cases

2011-03-21 Thread Tom Atkins
I am designing an app with a URL structure like this: myapp.com/yoursitename 'yoursitename' is effectively an argument as there could be many sites and users are allowed to create their own sites. But I'd like it to be 'top level'. Then within yoursitename there will be URLs like this: myapp.co

[web2py] Re: new URL router use cases

2011-03-02 Thread Massimo Di Pierro
or simply URL('static','images/filename') the f= and c= are no longer necessary. On Mar 2, 1:41 am, Jonathan Lundell wrote: > On Feb 22, 2011, at 11:47 PM, Johann Spies wrote: > > > Without the routes.py file I can work with the image in static/images but > > not when routes.py is active. > >

Re: [web2py] Re: new URL router use cases

2011-03-01 Thread Jonathan Lundell
On Feb 22, 2011, at 11:47 PM, Johann Spies wrote: > Without the routes.py file I can work with the image in static/images but not > when routes.py is active. Is it possible that you were using URL calls like this: URL(... c='static/images', f='filename') ? If so, try changing them to th

Re: [web2py] Re: new URL router use cases

2011-02-23 Thread Jonathan Lundell
On Feb 22, 2011, at 11:47 PM, Johann Spies wrote: > On 17 February 2011 21:33, Jonathan Lundell wrote: > On Feb 17, 2011, at 10:37 AM, Johann Spies wrote: > > What are the actual URLs for the images in question? As they appear in the > > page source at the browser, I mean. > > > > > > src="/kb/st

Re: [web2py] Re: new URL router use cases

2011-02-22 Thread Johann Spies
On 17 February 2011 21:33, Jonathan Lundell wrote: > On Feb 17, 2011, at 10:37 AM, Johann Spies wrote: > > What are the actual URLs for the images in question? As they appear in > the page source at the browser, I mean. > > > > > > src="/kb/static/DSC_1403.png" (I moved the image from /kb/static/

Re: [web2py] Re: new URL router use cases

2011-02-18 Thread pbreit
Ah, ok. Yeah it's working correctly.

Re: [web2py] Re: new URL router use cases

2011-02-18 Thread Jonathan Lundell
On Feb 18, 2011, at 12:57 PM, pbreit wrote: > How do I hide "/myapp/default" ? Just set default_application (in BASE) to "myapp". default_controller is set to "default" by default, and the rest happens automatically. I made a change just before the 1.92.1 release. By default, static URLs are no

[web2py] Re: new URL router use cases

2011-02-18 Thread pbreit
How do I hide "/myapp/default" ?

[web2py] Re: new URL router use cases

2011-02-18 Thread Anthony
This is great. To avoid confusion, though, would it make more sense to move this material into the "URL Rewrite" section of Chapter 4: http://web2py.com/book/default/chapter/04#URL-Rewrite Maybe keep the first paragraph of that section and then mention that there are now two distinct URL rewri

[web2py] Re: new URL router use cases

2011-02-18 Thread cjrh
On Feb 18, 8:16 pm, cjrh wrote: > Ok, here is a first draft. > > http://web2py.com/book/default/chapter/11#Modify-the-URL-with-the-Router http://web2py.com/book/default/chapter/11#Modifying-the-URL (refactored the section heading)

[web2py] Re: new URL router use cases

2011-02-18 Thread cjrh
On Feb 17, 8:02 am, Jonathan Lundell wrote: > Please do. Take a look at router.example.py as well; there's at least one new > feature there (path_prefix). I can review the material any time you're ready. Ok, here is a first draft. http://web2py.com/book/default/chapter/11#Modify-the-URL-with-th

Re: [web2py] Re: new URL router use cases

2011-02-18 Thread Jonathan Lundell
On Feb 17, 2011, at 10:37 AM, Johann Spies wrote: > src="/kb/static/DSC_1403.png" (I moved the image from /kb/static/images to > /kb/static - now it works. > > I would still like to know how to get imgages in static/images to work with > this routing system. I tested this with one of my apps

Re: [web2py] Re: new URL router use cases

2011-02-17 Thread Jonathan Lundell
On Feb 17, 2011, at 11:54 AM, pbreit wrote: > I'm still confused by routing. > > 1) I see routers.example.py and routes.example.py. Which do I use? Should it > be named routers.py or routes.py? Do they work together? Which can be used at > the app level? You choose one or the other, as routes.p

Re: [web2py] Re: new URL router use cases

2011-02-17 Thread pbreit
I'm still confused by routing. 1) I see routers.example.py and routes.example.py. Which do I use? Should it be named routers.py or routes.py? Do they work together? Which can be used at the app level? 2) What would a routing file look like that matches the current default routing behavior? I w

Re: [web2py] Re: new URL router use cases

2011-02-17 Thread Jonathan Lundell
On Feb 17, 2011, at 10:37 AM, Johann Spies wrote: > What are the actual URLs for the images in question? As they appear in the > page source at the browser, I mean. > > > src="/kb/static/DSC_1403.png" (I moved the image from /kb/static/images to > /kb/static - now it works. > > I would still

Re: [web2py] Re: new URL router use cases

2011-02-17 Thread Johann Spies
> No, this is a special case for favicon.ico and robots.txt > > By "root_static" (which I agree is a little confusing), we mean static > files like favicon.ico that are always accessed in the server root. This is > simply a list of those files (and the default list should normally be all > you need

Re: [web2py] Re: new URL router use cases

2011-02-17 Thread Jonathan Lundell
On Feb 17, 2011, at 4:58 AM, Johann Spies wrote: > On 17 February 2011 08:02, Jonathan Lundell wrote: > On Feb 16, 2011, at 9:49 PM, cjrh wrote: > > > > On Feb 16, 11:38 pm, Jonathan Lundell wrote: > >> [I'm reposting this message from a while back, because the new release > >> 1.92.1 contains i

Re: [web2py] Re: new URL router use cases

2011-02-17 Thread Johann Spies
On 17 February 2011 08:02, Jonathan Lundell wrote: > On Feb 16, 2011, at 9:49 PM, cjrh wrote: > > > > On Feb 16, 11:38 pm, Jonathan Lundell wrote: > >> [I'm reposting this message from a while back, because the new release > 1.92.1 contains it for the first time. It describes some simple use cas

[web2py] Re: new URL router use cases

2011-02-16 Thread cjrh
On Feb 17, 8:02 am, Jonathan Lundell wrote: > On Feb 16, 2011, at 9:49 PM, cjrh wrote: > > > On Feb 16, 11:38 pm, Jonathan Lundell wrote: > >> [I'm reposting this message from a while back, because the new release > >> 1.92.1 contains it for the first time. It describes some simple use cases >

Re: [web2py] Re: new URL router use cases

2011-02-16 Thread Jonathan Lundell
On Feb 16, 2011, at 9:49 PM, cjrh wrote: > > On Feb 16, 11:38 pm, Jonathan Lundell wrote: >> [I'm reposting this message from a while back, because the new release >> 1.92.1 contains it for the first time. It describes some simple use cases >> for the new URL router. Note that there are still s

[web2py] Re: new URL router use cases

2011-02-16 Thread cjrh
On Feb 16, 11:38 pm, Jonathan Lundell wrote: > [I'm reposting this message from a while back, because the new release 1.92.1 > contains it for the first time. It describes some simple use cases for the > new URL router. Note that there are still some things that you'll need the > existing regex