I would like to update this highly ranked post:

I created a new model secure.py and add:

############ FORCED SSL #############
session.secure()
if not request.is_https:
    redirect(URL(scheme='https', args=request.args, vars=request.vars))
#####################################

I skipped the cron part since scheduler has long since replaced cron in 
web2py

2. I need only to use https at server, not local development environment 
(127.0.0.1), so I put models/secure.py into my .gitignore

Hope this helps!

Best, Yi

On Friday, July 1, 2011 at 8:46:52 AM UTC-7, Ross Peoples wrote:
>
> I'm calling from external cron, which is why this option is not getting 
> set. So all I have to do is add --cronjob to my cron line and it's all set. 
> Alternatively, while trying to figure this problem out, I noticed that 
> global_settings.cmd_options.shell will return a string if run from the 
> shell, or None if run as a web request, so if I didn't want to (or 
> couldn't) add --cronjob to my script, then I could replace what I used 
> earlier with this:
>
> ############ FORCED SSL #############
> from gluon.settings import global_settings
> if global_settings.cmd_options.shell:
>     print 'Running as shell script.'
> elif not request.is_https:
>     session.secure()
>     redirect('https://%s/%s' % (request.env.http_host, 
> request.application))
> #####################################
>
> So I guess it's personal preference as to whether you would want to add 
> --cronjob or check global_settings.cmd_options.shell. Thanks for the help!
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to