[web2py] Re: Routing Help

2013-03-05 Thread Kory Prince
Please also note my setup:

https:nginx (load balancer with ssl) -> http:nginx -> uwsgi

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Routing help with url helper

2012-11-28 Thread Ashu Verma
Hi,

Thanks for your reply. 

But still this problem will exist as 

 {{=URL(f='temp.json', hmac_key="", user_signature=True)}}  will 
output something like below : 


 '/init/default/temp.json?_signature=88c1fcf27e16dc114ba7f9ce7700fa4ae7ed7267'

$c = 'init' 
$f  = 'default'

Therefore again i will get

invalid controller (init/default)  error. 
what i want is to remove the application name from url. But urls generated 
with URL() will have the application name. how to tackle this?




On Tuesday, November 27, 2012 9:35:17 PM UTC+5:30, Massimo Di Pierro wrote:
>
> This was a tricky one. The $f does not match the extension.
>
> routes_in = (
>   (  '/$c/$f' ,  '/init/$c/$f' ),
>   (  '/$c/$f\.$e' ,  '/init/$c/$f\.$e' ),
>   (  '/$c/$f/$anything' , '/init/$c/$f/$anything' )
> )
>
> routes_out = (
>   (  ''/init/$c/$f' ,  '/$c/$f' ),
>   (  ''/init/$c/$f\.$e' ,  '/$c/$f.$e' ),
>   (  ''/init/$c/$f/$anything' , '/$c/$f/$anything' )
> )
>
> notice you cannot reverse the routes with .
>
>
>
>
> On Friday, 9 November 2012 12:37:38 UTC-6, Ashu Verma wrote:
>>
>> Hi,
>>
>> i am having the basic routing where i omitted the application name in 
>> url. Below is the content of my routes.py
>>
>> default_application = 'init'   
>> default_controller = 'default'  
>> default_function = 'index' 
>>
>> routes_in = (
>>   (  '/$c/$f' ,  '/init/$c/$f' ),
>>   (  '/$c/$f/$anything' , '/init/$c/$f/$anything' )
>> )
>>
>> routes_out = [(x, y) for (y, x) in routes_in]
>>
>>
>>
>> But when i generate a url via URL helper
>>
>> {{=URL(f='temp.json', hmac_key="", user_signature=True)}}
>>
>>
>> This will generate a URL with application name which means that 
>> application name will be treated as controller and I will get a HTTP 404. 
>>
>> So either i create my URL manually, but then i wouldn't be able to use 
>> digitally signed url  or I should modify the routes.py which I am not able 
>> to figure out without dropping the URL routing.
>>
>> Also, I tried putting a=None and a=''  in URL helper, still application 
>> name is appending.
>>
>>
>> Thank you,
>> Ashu
>>
>>
>>

-- 





[web2py] Re: Routing help with url helper

2012-11-27 Thread Massimo Di Pierro
This was a tricky one. The $f does not match the extension.

routes_in = (
  (  '/$c/$f' ,  '/init/$c/$f' ),
  (  '/$c/$f\.$e' ,  '/init/$c/$f\.$e' ),
  (  '/$c/$f/$anything' , '/init/$c/$f/$anything' )
)

routes_out = (
  (  ''/init/$c/$f' ,  '/$c/$f' ),
  (  ''/init/$c/$f\.$e' ,  '/$c/$f.$e' ),
  (  ''/init/$c/$f/$anything' , '/$c/$f/$anything' )
)

notice you cannot reverse the routes with .




On Friday, 9 November 2012 12:37:38 UTC-6, Ashu Verma wrote:
>
> Hi,
>
> i am having the basic routing where i omitted the application name in url. 
> Below is the content of my routes.py
>
> default_application = 'init'   
> default_controller = 'default'  
> default_function = 'index' 
>
> routes_in = (
>   (  '/$c/$f' ,  '/init/$c/$f' ),
>   (  '/$c/$f/$anything' , '/init/$c/$f/$anything' )
> )
>
> routes_out = [(x, y) for (y, x) in routes_in]
>
>
>
> But when i generate a url via URL helper
>
> {{=URL(f='temp.json', hmac_key="", user_signature=True)}}
>
>
> This will generate a URL with application name which means that 
> application name will be treated as controller and I will get a HTTP 404. 
>
> So either i create my URL manually, but then i wouldn't be able to use 
> digitally signed url  or I should modify the routes.py which I am not able 
> to figure out without dropping the URL routing.
>
> Also, I tried putting a=None and a=''  in URL helper, still application 
> name is appending.
>
>
> Thank you,
> Ashu
>
>
>

-- 





[web2py] Re: Routing help

2012-07-11 Thread Anthony
Note, when you create or change routes.py, you need to reload it before it 
will take effect (either restart the server or click the "Reload routes" 
button in the admin interface).

Anthony

On Wednesday, July 11, 2012 5:14:20 PM UTC-4, Anthony wrote:
>
> web2py does not use a file called "router.py". All rewrite code goes in 
> routes.py. You can use either the parameter-based system (
> router.example.py is an example) *or* the pattern-based system (
> routes.example.py is an example), but not both.
>
> Anthony
>
> On Wednesday, July 11, 2012 4:49:33 PM UTC-4, Janath wrote:
>>
>> Hi, 
>> I am trying to make the home page of the  
>> http://111.111.111.11:8000/welcome/default/index
>>   
>> which is the default page loaded when I type   
>> http://111.111.111.11:8000,
>>  
>> to  
>> *http://111.111.111.11:8000
>> :pythonPsse/defult/index.html*
>>
>> having read the above articles, I created routes.py and router.py in the 
>> base web2py folder.
>>
>> and made following changes to each file:
>>
>> routes.py
>>
>> default_application = 'PythonPSSE'# ordinarily set in base routes.py
>> default_controller = 'default'  # ordinarily set in app-specific routes.py
>> default_function = 'index'  # ordinarily set in app-specific routes.py
>>
>> router.py
>>
>> routers = dict(
>> BASE = dict(
>> default_application = 'PythonPSSE',
>> default_controller = 'default',
>> default_function = 'index',
>> ),
>> )
>>
>> however, it has no effect on the web2py behaviour, pages are downloaded 
>> as they were.
>>
>> I am sorry about raising this issue again. 
>>
>> Thank yoy,
>>
>> Janath
>>
>>
>>
>>
>>
>>
>>
>>
>> On Friday, May 18, 2012 1:19:03 PM UTC-5, Alexander McLin wrote:
>>>
>>> Sorry I posted too early,
>>>
>>> My solution is:
>>>
>>> in routes.py in the base folder, where myapp is the actual name of the 
>>> application I'm developing.
>>>
>>> routes_app = ((r'/(?Pwelcome|admin|myapp)\b.*', r'\g'),)
>>>
>>> and in myapp's folder, I have another routes.py with the following,
>>>
>>> routes_in = ((r'/myapp/users/(?P\d*)', 
>>> r'/myapp/users/index/\g'),)
>>>
>>> routes_out = 
>>> ((r'/myapp/users/index/(?P\d*)', r'/myapp/users/\g'),')
>>>
>>> This is what worked for me. 
>>>
>>>
>>> Alex
>>>
>>>
>>> On Friday, May 18, 2012 2:11:28 PM UTC-4, Alexander McLin wrote:

 Sorry if I wasn't clear, I actually meant URLs of the following form, 
 myapp/controller/args to be mapped to myapp/controller/index/args. The 
 second point of confusion takes a different tack on web2py routing than 
 the 
 first point.

 I'll try to experiment with your solution though.

 For future notes, I actually got the pattern-matching solution working, 
 I realized that what I was missing was that I had to include my 
 application's name in the routes_app for the custom routes to be enabled.

 In any event, my solution is

 On Friday, May 18, 2012 9:17:30 AM UTC-4, Wikus van de Merwe wrote:
>
> OK, so you want /myapp/args to be mapped to 
> /myapp/default_controller/default_function/args. By default args would be 
> interpreted as a function name and will be mapped to 
> /myapp/default_controller/args. To change that you need to define a list 
> of 
> functions for the default controller. Then if args is not in that list it 
> would be mapped to /myapp/default_controller/default_function/args.
>
> routers = dict( 
> myapp = dict(
> default_controller = "default",
> default_function = "index",
> functions = ["fun1", "fun2", "fun3"]
> )
> )
>
>

[web2py] Re: Routing help

2012-07-11 Thread Anthony
web2py does not use a file called "router.py". All rewrite code goes in 
routes.py. You can use either the parameter-based system (router.example.py 
is an example) *or* the pattern-based system (routes.example.py is an 
example), but not both.

Anthony

On Wednesday, July 11, 2012 4:49:33 PM UTC-4, Janath wrote:
>
> Hi, 
> I am trying to make the home page of the  
> http://111.111.111.11:8000/welcome/default/index
>   
> which is the default page loaded when I type   
> http://111.111.111.11:8000, 
> to  
> *http://111.111.111.11:8000
> :pythonPsse/defult/index.html*
>
> having read the above articles, I created routes.py and router.py in the 
> base web2py folder.
>
> and made following changes to each file:
>
> routes.py
>
> default_application = 'PythonPSSE'# ordinarily set in base routes.py
> default_controller = 'default'  # ordinarily set in app-specific routes.py
> default_function = 'index'  # ordinarily set in app-specific routes.py
>
> router.py
>
> routers = dict(
> BASE = dict(
> default_application = 'PythonPSSE',
> default_controller = 'default',
> default_function = 'index',
> ),
> )
>
> however, it has no effect on the web2py behaviour, pages are downloaded as 
> they were.
>
> I am sorry about raising this issue again. 
>
> Thank yoy,
>
> Janath
>
>
>
>
>
>
>
>
> On Friday, May 18, 2012 1:19:03 PM UTC-5, Alexander McLin wrote:
>>
>> Sorry I posted too early,
>>
>> My solution is:
>>
>> in routes.py in the base folder, where myapp is the actual name of the 
>> application I'm developing.
>>
>> routes_app = ((r'/(?Pwelcome|admin|myapp)\b.*', r'\g'),)
>>
>> and in myapp's folder, I have another routes.py with the following,
>>
>> routes_in = ((r'/myapp/users/(?P\d*)', r'/myapp/users/index/\g'),)
>>
>> routes_out = 
>> ((r'/myapp/users/index/(?P\d*)', r'/myapp/users/\g'),')
>>
>> This is what worked for me. 
>>
>>
>> Alex
>>
>>
>> On Friday, May 18, 2012 2:11:28 PM UTC-4, Alexander McLin wrote:
>>>
>>> Sorry if I wasn't clear, I actually meant URLs of the following form, 
>>> myapp/controller/args to be mapped to myapp/controller/index/args. The 
>>> second point of confusion takes a different tack on web2py routing than the 
>>> first point.
>>>
>>> I'll try to experiment with your solution though.
>>>
>>> For future notes, I actually got the pattern-matching solution working, 
>>> I realized that what I was missing was that I had to include my 
>>> application's name in the routes_app for the custom routes to be enabled.
>>>
>>> In any event, my solution is
>>>
>>> On Friday, May 18, 2012 9:17:30 AM UTC-4, Wikus van de Merwe wrote:

 OK, so you want /myapp/args to be mapped to 
 /myapp/default_controller/default_function/args. By default args would be 
 interpreted as a function name and will be mapped to 
 /myapp/default_controller/args. To change that you need to define a list 
 of 
 functions for the default controller. Then if args is not in that list it 
 would be mapped to /myapp/default_controller/default_function/args.

 routers = dict( 
 myapp = dict(
 default_controller = "default",
 default_function = "index",
 functions = ["fun1", "fun2", "fun3"]
 )
 )



[web2py] Re: Routing help

2012-07-11 Thread Janath
Hi, 
I am trying to make the home page of the  
http://111.111.111.11:8000/welcome/default/index
  
which is the default page loaded when I type   
http://111.111.111.11:8000, 
to  
*http://111.111.111.11:8000
:pythonPsse/defult/index.html*

having read the above articles, I created routes.py and router.py in the 
base web2py folder.

and made following changes to each file:

routes.py

default_application = 'PythonPSSE'# ordinarily set in base routes.py
default_controller = 'default'  # ordinarily set in app-specific routes.py
default_function = 'index'  # ordinarily set in app-specific routes.py

router.py

routers = dict(
BASE = dict(
default_application = 'PythonPSSE',
default_controller = 'default',
default_function = 'index',
),
)

however, it has no effect on the web2py behaviour, pages are downloaded as 
they were.

I am sorry about raising this issue again. 

Thank yoy,

Janath








On Friday, May 18, 2012 1:19:03 PM UTC-5, Alexander McLin wrote:
>
> Sorry I posted too early,
>
> My solution is:
>
> in routes.py in the base folder, where myapp is the actual name of the 
> application I'm developing.
>
> routes_app = ((r'/(?Pwelcome|admin|myapp)\b.*', r'\g'),)
>
> and in myapp's folder, I have another routes.py with the following,
>
> routes_in = ((r'/myapp/users/(?P\d*)', r'/myapp/users/index/\g'),)
>
> routes_out = 
> ((r'/myapp/users/index/(?P\d*)', r'/myapp/users/\g'),')
>
> This is what worked for me. 
>
>
> Alex
>
>
> On Friday, May 18, 2012 2:11:28 PM UTC-4, Alexander McLin wrote:
>>
>> Sorry if I wasn't clear, I actually meant URLs of the following form, 
>> myapp/controller/args to be mapped to myapp/controller/index/args. The 
>> second point of confusion takes a different tack on web2py routing than the 
>> first point.
>>
>> I'll try to experiment with your solution though.
>>
>> For future notes, I actually got the pattern-matching solution working, I 
>> realized that what I was missing was that I had to include my application's 
>> name in the routes_app for the custom routes to be enabled.
>>
>> In any event, my solution is
>>
>> On Friday, May 18, 2012 9:17:30 AM UTC-4, Wikus van de Merwe wrote:
>>>
>>> OK, so you want /myapp/args to be mapped to 
>>> /myapp/default_controller/default_function/args. By default args would be 
>>> interpreted as a function name and will be mapped to 
>>> /myapp/default_controller/args. To change that you need to define a list of 
>>> functions for the default controller. Then if args is not in that list it 
>>> would be mapped to /myapp/default_controller/default_function/args.
>>>
>>> routers = dict( 
>>> myapp = dict(
>>> default_controller = "default",
>>> default_function = "index",
>>> functions = ["fun1", "fun2", "fun3"]
>>> )
>>> )
>>>
>>>

[web2py] Re: Routing help

2012-05-18 Thread Alexander McLin
Sorry I posted too early,

My solution is:

in routes.py in the base folder, where myapp is the actual name of the 
application I'm developing.

routes_app = ((r'/(?Pwelcome|admin|myapp)\b.*', r'\g'),)

and in myapp's folder, I have another routes.py with the following,

routes_in = ((r'/myapp/users/(?P\d*)', r'/myapp/users/index/\g'),)

routes_out = ((r'/myapp/users/index/(?P\d*)', r'/myapp/users/\g'),')

This is what worked for me. 


Alex


On Friday, May 18, 2012 2:11:28 PM UTC-4, Alexander McLin wrote:
>
> Sorry if I wasn't clear, I actually meant URLs of the following form, 
> myapp/controller/args to be mapped to myapp/controller/index/args. The 
> second point of confusion takes a different tack on web2py routing than the 
> first point.
>
> I'll try to experiment with your solution though.
>
> For future notes, I actually got the pattern-matching solution working, I 
> realized that what I was missing was that I had to include my application's 
> name in the routes_app for the custom routes to be enabled.
>
> In any event, my solution is
>
> On Friday, May 18, 2012 9:17:30 AM UTC-4, Wikus van de Merwe wrote:
>>
>> OK, so you want /myapp/args to be mapped to 
>> /myapp/default_controller/default_function/args. By default args would be 
>> interpreted as a function name and will be mapped to 
>> /myapp/default_controller/args. To change that you need to define a list of 
>> functions for the default controller. Then if args is not in that list it 
>> would be mapped to /myapp/default_controller/default_function/args.
>>
>> routers = dict( 
>> myapp = dict(
>> default_controller = "default",
>> default_function = "index",
>> functions = ["fun1", "fun2", "fun3"]
>> )
>> )
>>
>>

[web2py] Re: Routing help

2012-05-18 Thread Alexander McLin
Sorry if I wasn't clear, I actually meant URLs of the following form, 
myapp/controller/args to be mapped to myapp/controller/index/args. The 
second point of confusion takes a different tack on web2py routing than the 
first point.

I'll try to experiment with your solution though.

For future notes, I actually got the pattern-matching solution working, I 
realized that what I was missing was that I had to include my application's 
name in the routes_app for the custom routes to be enabled.

In any event, my solution is

On Friday, May 18, 2012 9:17:30 AM UTC-4, Wikus van de Merwe wrote:
>
> OK, so you want /myapp/args to be mapped to 
> /myapp/default_controller/default_function/args. By default args would be 
> interpreted as a function name and will be mapped to 
> /myapp/default_controller/args. To change that you need to define a list of 
> functions for the default controller. Then if args is not in that list it 
> would be mapped to /myapp/default_controller/default_function/args.
>
> routers = dict( 
> myapp = dict(
> default_controller = "default",
> default_function = "index",
> functions = ["fun1", "fun2", "fun3"]
> )
> )
>
>

[web2py] Re: Routing help

2012-05-18 Thread Alexander McLin
Thank you for the clarification, I understand it better now. I was indeed 
confused by the statement you quoted, I had thought that web2py's base 
behavior would that if it couldn't find a controller corresponding to 
somefunction, it would then invoke the default controller and search for 
somefunction on it which then successfully executes. Of course if the 
default controller doesn't have somefunction then web2py's final action 
would be to return an error.

Alex

On Thursday, May 17, 2012 5:57:54 PM UTC-4, Anthony wrote:
>
> The web2py book and documentation has led me to believe that the following 
>> would work;
>>
>> http://120.0.0.1/myapp/default/somefunction can be written as 
>> http://120.0.0.1/myapp/somefunction but I get invalid request error
>>
>
> Here's what the book says:
>
> web2py maps a URL of the form:
>
> 1.
>
> http://127.0.0.1:8000/a/c/f.html
>
> to the function f() in controller "c.py" in application "a". If f is not 
> present, web2py defaults to the indexcontroller function. If c is not 
> present, web2py defaults to the "default.py" controller, and if a is not 
> present, web2py defaults to the init application. If there is no init 
> application, 
> web2py tries to run the welcomeapplication.
>
> I think I see the confusion. It says if the controller is not present, 
> web2py defaults to the default.py controller. However, when you have the 
> URL /myapp/somefunction, technically the controller is present, as web2py 
> will interpret the second element of the URL as the controller (just 
> because you know somefunction is a function doesn't mean the default router 
> does) -- in that case, it's actually the function that is missing, not the 
> controller. So, what the above really means is:
>
> /myapp maps to /myapp/default/index
> /myapp/default maps to /myapp/default/index
>
> but /myapp/somefunction does not map to /myapp/default/somefunction 
> because somefunction is interpreted as a controller in that URL (instead, 
> it maps to /myapp/somefunction/index, and you get an error because such a 
> controller doesn't exist).
>  
>
>> If I then overwrite routes.py using routes.example.py, the above case no 
>> longer works. Looking at both routes.example.py and router.example.py, 
>> it looks like both of them configure web2py's routing behavior in the same 
>> way, but the actual behavior is not the same.
>>
>
> I assume you're referring to the default_controller='default' parameter 
> set in the routes.example.py example. I agree that's a little confusing 
> because you might expect it to work much like setting the default 
> controller in the parameter-based system, but again, let's look at what the 
> book says:
>
> When using the pattern-based system, the name of the default application, 
> controller, and function can be changed from *init*, *default*, and *index
> * respectively to another name by setting the appropriate value in 
> routes.py 
>
>
> That's saying that setting the value of default_controller merely changes 
> the default value used by the standard routing system when that item is 
> missing from the URL. So, let's say you set 
> default_controller='mycontroller'. In that case, /myapp would map to 
> /myapp/mycontroller/index instead of /myapp/default/index, but 
> /myapp/somefunction would still cause a problem because somefunction would 
> be seen as a controller.
>
> One thing to note is that the parameter-based system was created quite a 
> while after the pattern-based system, so seemingly similar functionality 
> wasn't necessarily designed to behave the same way (hopefully the behavior 
> of the parameter-based system is seen as an improvement in this case).
>
> Anyway, I agree some of this could be better explained in the book.
>
> Anthony
>
>

[web2py] Re: Routing help

2012-05-18 Thread Wikus van de Merwe
OK, so you want /myapp/args to be mapped to 
/myapp/default_controller/default_function/args. By default args would be 
interpreted as a function name and will be mapped to 
/myapp/default_controller/args. To change that you need to define a list of 
functions for the default controller. Then if args is not in that list it 
would be mapped to /myapp/default_controller/default_function/args.

routers = dict( 
myapp = dict(
default_controller = "default",
default_function = "index",
functions = ["fun1", "fun2", "fun3"]
)
)



[web2py] Re: Routing help

2012-05-18 Thread Deidre
" 
but /myapp/somefunction does not map to /myapp/default/somefunction because 
somefunction is interpreted as a controller in that URL (instead, it maps 
to /myapp/somefunction/index, and you get an error because such a 
controller doesn't exist).
"

so what does one do if one wants

myapp/somestuff

to map to a function that can then interpret 'somestuff' via 
response.args(0)

if one sets up defaults, then the sytstem will look for 

myapp/somestuff/index

which is not what is wanted.

Peter

On Thursday, May 17, 2012 8:44:02 PM UTC+1, AlexBenjM wrote:
>
> Hello,
>
> I'm new to web2py and am having a difficult time understanding how to use 
> either the parameter or pattern based systems as well how web2py default 
> routing works.
>
> *I'll start off with the first point of confusion for me;*
>
> The web2py book and documentation has led me to believe that the following 
> would work;
>
> http://120.0.0.1/myapp/default/somefunction can be written as 
> http://120.0.0.1/myapp/somefunction but I get invalid request error
>
> If I copy router.example.py to routes.py in the base directory, the above 
> case then works as I expected, but I thought that even with a lack of a 
> routes.py file, web2py would still automatically default to the same 
> behavior. This isn't so at all?
>
> If I then overwrite routes.py using routes.example.py, the above case no 
> longer works. Looking at both routes.example.py and router.example.py, it 
> looks like both of them configure web2py's routing behavior in the same 
> way, but the actual behavior is not the same.
>
> So I'm pretty confused about this. Note, after each changes to routes.py I 
> do reload the routes in web2py's admin console.
>
> *The second point of confusion for me is;*
> *
> *
> In the application I'm writing, which uses AJAX heavily and uses PUT and 
> DELETE in addition to GET and POST.
>
> I have in one of the controller, users, the following;
>
> def index():
> def GET():
>blah
> def POST(*vars, **fields):
>   blah
> def PUT(*vars, **fields):
>   blah
> def DELETE(*vars, **fields):
>   blah
>
> I want to map a PUT request to users/5 to users/index/5
>
> Right now the current default routing configuration returns users/5 as 
> invalid request which is expected. Unfortunately I still don't understand 
> web2py well enough to know how to set up one of the routing systems to map 
> users/ to users/index/
>
> I think I need to use the pattern matching system but I'm not able to get 
> it working properly.
>
> Would appreciate your tips.
>
> Thanks
> Alex
>
>

[web2py] Re: Routing help

2012-05-17 Thread Anthony

>
> The web2py book and documentation has led me to believe that the following 
> would work;
>
> http://120.0.0.1/myapp/default/somefunction can be written as 
> http://120.0.0.1/myapp/somefunction but I get invalid request error
>

Here's what the book says:

web2py maps a URL of the form:

1.

http://127.0.0.1:8000/a/c/f.html

to the function f() in controller "c.py" in application "a". If f is not 
present, web2py defaults to the indexcontroller function. If c is not 
present, web2py defaults to the "default.py" controller, and if a is not 
present, web2py defaults to the init application. If there is no init 
application, 
web2py tries to run the welcomeapplication.

I think I see the confusion. It says if the controller is not present, 
web2py defaults to the default.py controller. However, when you have the 
URL /myapp/somefunction, technically the controller is present, as web2py 
will interpret the second element of the URL as the controller (just 
because you know somefunction is a function doesn't mean the default router 
does) -- in that case, it's actually the function that is missing, not the 
controller. So, what the above really means is:

/myapp maps to /myapp/default/index
/myapp/default maps to /myapp/default/index

but /myapp/somefunction does not map to /myapp/default/somefunction because 
somefunction is interpreted as a controller in that URL (instead, it maps 
to /myapp/somefunction/index, and you get an error because such a 
controller doesn't exist).
 

> If I then overwrite routes.py using routes.example.py, the above case no 
> longer works. Looking at both routes.example.py and router.example.py, it 
> looks like both of them configure web2py's routing behavior in the same 
> way, but the actual behavior is not the same.
>

I assume you're referring to the default_controller='default' parameter set 
in the routes.example.py example. I agree that's a little confusing because 
you might expect it to work much like setting the default controller in the 
parameter-based system, but again, let's look at what the book says:

When using the pattern-based system, the name of the default application, 
controller, and function can be changed from *init*, *default*, and *index* 
respectively 
to another name by setting the appropriate value in routes.py 


That's saying that setting the value of default_controller merely changes 
the default value used by the standard routing system when that item is 
missing from the URL. So, let's say you set 
default_controller='mycontroller'. In that case, /myapp would map to 
/myapp/mycontroller/index instead of /myapp/default/index, but 
/myapp/somefunction would still cause a problem because somefunction would 
be seen as a controller.

One thing to note is that the parameter-based system was created quite a 
while after the pattern-based system, so seemingly similar functionality 
wasn't necessarily designed to behave the same way (hopefully the behavior 
of the parameter-based system is seen as an improvement in this case).

Anyway, I agree some of this could be better explained in the book.

Anthony



[web2py] Re: Routing help

2012-05-17 Thread pbreit
Oh, I see, that's how you code the REST stuff. My bad.

[web2py] Re: Routing help

2012-05-17 Thread pbreit
I believe to hide 'default' and 'index' you need to use routes.py and:

routers = dict(

# base router
BASE = dict(
default_application = 'init',
default_controller = 'default',
default_function = 'index',
),
)

Setting the default application will hide it as well.

Can you do it like this:

def users():
if request.method == 'POST':
id = request.args(0)
...