> Shouldn't there be a non-google value set somewhere else
> (wsgihandler.py?) and what would the value be ('WSGI'?)?

When web2py does its detection in main.py, it can do:

runtime = os.environ.get('WEB2PY_RUNTIME']','DEFAULT')

> Would it be prefereable to be a boolean (IS_GAE=True) and set
> elsewhere to False? (I suppose this has problem if another application
> engine comes along).

Yeah, it would be handy to be able to be able to check for known
runtimes:
request.env.runtime.is_gae?

>
> As there is already an environ key 'SERVER_SOFTWARE' why create
> another key 'WEB2PY_MODE'?

Google is setting SERVER_SOFTWARE in this case:

if os.environ.get('SERVER_SOFTWARE','').startswith('Devel'):

gaehandler.py code should only set WEB2PY_MODE if it was not
externally set by the developer

this way the developer can test production mode on localhost

export WEB2PY_MODE=PRODUCTION
dev_appserver.py .

>
> Bill
>
> On Feb 1, 12:36 pm, Robin B <robi...@gmail.com> wrote:
>
> > You are right importing 'google' is insufficient for detection, but
> > detecting GAE side effects is only slightly better.
>
> > All GAE apps start in gaehandler.py.  Simply set the environment
> > variables in side of gaehandler.py, it results in 100% fool proof
> > detection.
>
> > At the top of gaelhander.py:
>
> > # foolproof detection in 1 line
> > os.environ['WEB2PY_RUNTIME'] = 'GOOGLE'
> > # also set the mode
> > if os.environ.get('SERVER_SOFTWARE','').startswith('Devel'):
> >   os.environ['WEB2PY_MODE'] = 'DEVELOPMENT'
> > else:
> >   os.environ['WEB2PY_MODE'] = 'PRODUCTION'
>
> > Robin
>
> > On Feb 1, 4:35 am, billf <billferr...@blueyonder.co.uk> wrote:
>
> > > As a short-term solution, I am using the following patch:
>
> > > In compileapp.py, is_gae is set depending on the result of
> > > imp.get_magic() so in build_environment() in the same module I store
> > > is_gae in environment['GAE'].  Then in db.py I can say
>
> > > if globals()['GAE']: before importing google stuff and using GQLDB()
>
> > > Have I a) re-invented the wheel, b) come up with a good solution, c)
> > > missed something important?
>
> > > On Feb 1, 9:06 am, billf <billferr...@blueyonder.co.uk> wrote:
>
> > > > I have installed the google appengine but do not want web2py to use
> > > > the google datastore just because the libs are there but that is what
> > > > the welcome app does.
>
> > > > I have read some threads related to detecting GAE but they seemed
> > > > inconclusive.
>
> > > > Is there a way that, in a model (or elsewhere for that matter) I can
> > > > detect if the app is running on GAE that doesn't depend on the
> > > > presence of google libs?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to