Actually, scratch that. When running in Apache,
global_settings.cmd_options is set to None, so I guess you could do
some extra checking there to make sure it initialized, then check the
shell variable, but it's way easier to just add --cronjob and just
check global_settings.cronjob.

And Google Groups is giving me a lot of trouble. This is the 3rd time
I've tried to post this, so I apologize if this shows up several
times.

On Jul 1, 11:46 am, Ross Peoples <[email protected]> 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!

Reply via email to