[web2py] Re: Default controller function

2012-02-01 Thread nick name
Working with unsanitized input like this might be dangerous. 

http://localhost/content/../../../etc/passwd


[web2py] Re: Default controller function

2012-01-31 Thread Massimo Di Pierro
How about this?


{{extend 'layout.html'}}
    div id=homeContent
        {{include default/content.html'}}
    /div

you do not need a controller function to include a view.

On Jan 31, 4:18 pm, Ed Greenberg greenberg...@gmail.com wrote:
 I have some html files which I want to render inside the layout.
 Something like this:

 {{extend 'layout.html'}}
     div id=homeContent
         content goes here
     /div

 All it needs is an empty dict, since it won't look for anything from
 the controller to customize it.

 I put this file in views/default/content.html

 My understanding is that I need a function in controllers/default.py
 called content().  Without it, I get Invalid Function default/
 content

 Since I expect more than one file of this nature, I'd prefer not to
 create a whole bunch of virtually empty controller functions.   Is
 there any way to have a default controller function?

 Thanks,
 Ed


[web2py] Re: Default controller function

2012-01-31 Thread pbreit
You pretty much need to add both a controller function and a view to add 
static pages like that.

Otherwise, you would need to program some sort of traffic cop to see the 
incoming request and manually render it with a view.

So create a controller content.py with something like this:

def index():
return response.render('content/%s' % request.args(0))

Put your views in views/content

Then a URL like:
http://localhost/content/about

Should map to the view at views/content/about.html


[web2py] Re: Default controller function

2012-01-31 Thread Massimo Di Pierro
You can always put the static pages into app/static/

On Jan 31, 6:51 pm, pbreit pbreitenb...@gmail.com wrote:
 You pretty much need to add both a controller function and a view to add
 static pages like that.

 Otherwise, you would need to program some sort of traffic cop to see the
 incoming request and manually render it with a view.

 So create a controller content.py with something like this:

 def index():
     return response.render('content/%s' % request.args(0))

 Put your views in views/content

 Then a URL like:http://localhost/content/about

 Should map to the view at views/content/about.html