Re: [web2py] routes, removing appname and controller from all links

2013-03-01 Thread Rufus Smith

I anticipated that, because I tried it.

I added:

routes_onerror = [
   (r'*/*', r'error')
]

to call an error function. in this case, /myapp/default/error



On 3/1/2013 7:14 PM, jjg0 wrote:
Oh I wish it were that simple, but no I still see invalid requests 
when trying that:(


Can anyone help me with this?  I still have not resolved this issue.




On Friday, March 1, 2013 5:49:46 PM UTC-5, Rufus wrote:

# As simple as this?   (I'm new too)

routes_in = (
('/$anything', '/myapp/default/$anything'),
)

routes_out = (
('/myapp/default/$anything', '/$anything'),
)


--

---
You received this message because you are subscribed to a topic in the 
Google Groups "web2py-users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/web2py/IjE2kSJ9j68/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to 
web2py+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.




--

--- 
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.




Re: [web2py] routes, removing appname and controller from all links

2013-03-01 Thread Jonathan Lundell
On 1 Mar 2013, at 4:14 PM, jjg0  wrote:
> Oh I wish it were that simple, but no I still see invalid requests when 
> trying that:(  
> 
> Can anyone help me with this?  I still have not resolved this issue.

When you use the parametric router, what exactly is the complete error message 
(please specify the URL as well)?

-- 

--- 
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.




Re: [web2py] routes, removing appname and controller from all links

2013-03-01 Thread jjg0
Oh I wish it were that simple, but no I still see invalid requests when 
trying that:(  

Can anyone help me with this?  I still have not resolved this issue.




On Friday, March 1, 2013 5:49:46 PM UTC-5, Rufus wrote:
>
> # As simple as this?   (I'm new too)
>
> routes_in = (
> ('/$anything', '/myapp/default/$anything'),
> )
>
> routes_out = (
> ('/myapp/default/$anything', '/$anything'),
> )
>
>
>

-- 

--- 
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.




Re: [web2py] routes, removing appname and controller from all links

2013-03-01 Thread Rufus
# As simple as this?   (I'm new too)

routes_in = (
('/$anything', '/myapp/default/$anything'),
)

routes_out = (
('/myapp/default/$anything', '/$anything'),
)


-- 

--- 
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.




Re: [web2py] routes, removing appname and controller from all links

2013-03-01 Thread jjg0
As I mentioned, I am restarting the server with every change to routes.py.  
I tried using:

routers = dict(

# base router
BASE=dict(
default_application='myapp',
),
) 

But this still does not solve my problem.  I need *every *page to hide the 
app name and controller, not just the default index page.  Right now I am 
just trying to get this working in an empty project, so my default 
controller looks like:

def index():
return dict()

def contactus():
return dict()

and the two corresponding views are just using {{extend 'layout.html'}} and 
then left empty at the moment.

Using this and the above routes.py example, I can go to 127.0.0.1.8000 on 
my local server and I will see the index page without having to add 
/myapp/default/index to the url.  So it looks like the routes.py is doing 
something right, however if I try 127.0.0.1:8000/contactus I get an invalid 
request.  Using 127.0.0.1:8000/myapp/default/contactus works fine, but I 
don't want the app and controller in the url.

Hope my explanation of the problem is clear.

Thanks



On Friday, March 1, 2013 10:51:29 AM UTC-5, Jonathan Lundell wrote:
>
> On 1 Mar 2013, at 6:42 AM, jjg0 > wrote:
>
> I saw in another question someone posted an example using the parameter 
> based system:
>
>
> routers = dict(
>
> # base router
> BASE=dict(
> default_application='myapp',
> ),
>
> myapp=dict(
> default_controller='default',
> default_function='index',
> functions=['index', 'contactus'],
> ),
> ) 
>
> where I guess you have to type in every function in the default 
> controller?  
>
>
> Only if you want to omit function names at the same time you have args 
> following the function. Otherwise, no need. To accomplish what you're 
> after, all you need (because default/index is already the deafult) is:
>
> routers = dict(
>
> # base router
> BASE=dict(
> default_application='myapp',
> ),
> ) 
>
> This still doesn't solve my problem.  Using these settings does the same 
> thing where going to 127.0.0.1:8000 will take you to 
> 127.0.0.1:8000/myapp/default/index, but trying any other page like 
> 127.0.0.1:8000/contactus does not work.  
>
>
> It should. Be sure to restart your server/web2py after editing routes.py, 
> though.
>
> I still need to use 127.0.0.1:8000/myapp/default/ for any 
> additional pages I add.
>
>
>
>

-- 

--- 
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.




Re: [web2py] routes, removing appname and controller from all links

2013-03-01 Thread Jonathan Lundell
On 1 Mar 2013, at 6:42 AM, jjg0  wrote:
> I saw in another question someone posted an example using the parameter based 
> system:
> 
> 
> routers = dict(
> 
> # base router
> BASE=dict(
> default_application='myapp',
> ),
> 
> myapp=dict(
> default_controller='default',
> default_function='index',
> functions=['index', 'contactus'],
> ),
> ) 
> 
> where I guess you have to type in every function in the default controller? 

Only if you want to omit function names at the same time you have args 
following the function. Otherwise, no need. To accomplish what you're after, 
all you need (because default/index is already the deafult) is:

routers = dict(

# base router
BASE=dict(
default_application='myapp',
),
) 

> This still doesn't solve my problem.  Using these settings does the same 
> thing where going to 127.0.0.1:8000 will take you to 
> 127.0.0.1:8000/myapp/default/index, but trying any other page like 
> 127.0.0.1:8000/contactus does not work. 

It should. Be sure to restart your server/web2py after editing routes.py, 
though.

> I still need to use 127.0.0.1:8000/myapp/default/ for any 
> additional pages I add.


-- 

--- 
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] routes, removing appname and controller from all links

2013-03-01 Thread jjg0
I've been having a lot of trouble trying to clean up my URLs.  If my app 
name is myapp, and I go out an buy the domain myapp.com, when I deploy the 
site all the urls are going to read www.myapp.com/myapp/default/function.  
How do I get rid of the app name and controller?

I've read the section in the book but did not find it very helpful.  If I 
set 

default_application = 'myapp'# 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

This works for the index function, so if I go to my local server 
127.0.0.1:8000 I will see the page from myapp/default/index.  But if I add 
another page, for example myapp/default/contactus, I want to be able to 
just enter 127.0.0.1:8000/contactus instead of 
127.0.0.1:8000/myapp/default/contactus.

I saw in another question someone posted an example using the parameter 
based system:


routers = dict(

# base router
BASE=dict(
default_application='myapp',
),

myapp=dict(
default_controller='default',
default_function='index',
functions=['index', 'contactus'],
),
) 

where I guess you have to type in every function in the default 
controller?  This still doesn't solve my problem.  Using these settings 
does the same thing where going to 127.0.0.1:8000 will take you to 
127.0.0.1:8000/myapp/default/index, but trying any other page like 
127.0.0.1:8000/contactus does not work.  I still need to use 
127.0.0.1:8000/myapp/default/ for any additional pages I add.

The pattern based system seems a bit more confusing.  Do people typically 
use this over the parameter one?  Is the parameter one more of a crutch for 
new users?  I tried adding to routes_in:

('/contactus', '/myapp/default/contactus'),

in hopes that using 127.0.0.1:8000/contactus would take me to 
127.0.0.1:/8000/myapp/default/contactus, but this seems to have no effect.  
Are there better tutorials on how to use route_in/out? Will I have to add 
an entry to routes for every page I add, or are there shortcuts?

Thanks

*One side note, I saw routes.py needs to be reloaded every time it is 
changed, so I have been restarting the server when testing these examples.





-- 

--- 
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.