Ah, thank you for the advice on removing main.py. And my folder structure
is similar to that, with one change. I don't quite remember if this is
something I did manually per my instructor's advice, but instead of
web2py/, my folder is called web2py-class. I do have a folder called web2py
located elsewhere on my computer, though. Should I move my application from
web2py-class/applications/ to web2py/applications? Thank you so much.
On Monday, December 7, 2015 at 6:57:31 AM UTC-8, Massimo Di Pierro wrote:
>
> You should not need that main.py in web2py. web2py does not uses webapp2.
> You only need app.py and gaehandler.py They look correct. The error is from
> this lines in gaehandler:
>
>
> if not os.path.isdir('applications'):
> raise RuntimeError('Running from the wrong folder')
>
>
> Do you have the correct folder structure?
>
> web2py/
> app.yaml
> gaehandler.py
> web2py.py
> applications/...
> gluon/...
> [etc etc]
>
>
> On Monday, 7 December 2015 06:40:49 UTC-6, Brad Cardello wrote:
>>
>> Hey everyone, I'm still fairly new to web2py, and completely new to
>> deploying my website (developed using PyCharm, if that matters). So, here's
>> the error I'm getting in the logs whenever I try to access my website:
>>
>> Traceback (most recent call last):
>>>
>>> File "C:\Program Files
>>> (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 240,
>>> in Handle
>>>
>>> handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
>>>
>>> File "C:\Program Files
>>> (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 299,
>>> in _LoadHandler
>>>
>>> handler, path, err = LoadObject(self._handler)
>>>
>>> File "C:\Program Files
>>> (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 85,
>>> in LoadObject
>>>
>>> obj = __import__(path[0])
>>>
>>> File "C:\Users\Brad Cardello\Desktop\Computer
>>> Science\CMPS-183\web2py-class\applications\WebUcscTutor\gaehandler.py",
>>> line 40, in <module>
>>>
>>> raise RuntimeError('Running from the wrong folder')
>>>
>>> RuntimeError: Running from the wrong folder
>>>
>>> INFO 2015-12-07 01:10:16,092 module.py:787] default: "GET /
>>> HTTP/1.1" 500 -
>>
>>
>>
>> I'm really not sure why this is happening, as it gives me this error no
>> matter where gaehandler.py is located in my file system. At the moment, per
>> multiple people's instructions, my app.yaml, gaehandler.py, and main.py are
>> all in the root directory for my project
>> (/web2py-class/applications/WebUcscTutor). I've tried moving it to
>> web2py-class/applications, and web2py-class, but nothing seems to change
>> this error.
>>
>> Here's my *app.yaml*
>>
>> # For Google App Engine deployment, copy this file to app.yaml
>> # and edit as required
>> # See http://code.google.com/appengine/docs/python/config/appconfig.html
>> # and http://web2py.com/book/default/chapter/11?search=app.yaml
>>
>> application: ucsc-tutor-website
>> version: 1
>> api_version: 1
>>
>> # use these lines for Python 2.7
>> # upload app with: appcfg.py update web2py (where 'web2py' is web2py's root
>> directory)
>> #
>> runtime: python27
>> threadsafe: true # true for WSGI & concurrent requests (Python 2.7 only)
>>
>> default_expiration: "1m" # for static files
>>
>> handlers:
>>
>> # Warning! Static mapping - below - isn't compatible with
>> # the parametric router's language logic.
>> # You cannot use them together.
>>
>> - url: /(.+?)/static/_(\d+\.\d+\.\d+)\/(.+)
>> static_files: applications/\1/static/\3
>> upload: applications/(.+?)/static/(.+)
>> secure: optional
>> expiration: "365d"
>>
>> - url: /(.+?)/static/(.+)
>> static_files: applications/\1/static/\2
>> upload: applications/(.+?)/static/(.+)
>> secure: optional
>>
>> - url: /favicon.ico
>> static_files: applications/welcome/static/favicon.ico
>> upload: applications/welcome/static/favicon.ico
>>
>> - url: /robots.txt
>> static_files: applications/welcome/static/robots.txt
>> upload: applications/welcome/static/robots.txt
>>
>> - url: .*
>> script: gaehandler.wsgiapp # WSGI (Python 2.7 only)
>> secure: optional
>>
>> admin_console:
>> pages:
>> - name: Appstats
>> url: /_ah/stats
>>
>> skip_files: |
>> ^(.*/)?(
>> (app\.yaml)|
>> (app\.yml)|
>> (index\.yaml)|
>> (index\.yml)|
>> (#.*#)|
>> (.*~)|
>> (.*\.py[co])|
>> (.*/RCS/.*)|
>> (\..*)|
>> (applications/examples/.*)|
>> ((examples|welcome)\.(w2p|tar))|
>> (applications/.*?/(cron|databases|errors|cache|sessions)/.*)|
>> ((logs|scripts)/.*)|
>> (anyserver\.py)|
>> (web2py\.py)|
>> ((cgi|fcgi|modpython|wsgi)handler\.py)|
>> (epydoc\.(conf|css))|
>> (httpserver\.log)|
>> (logging\.example\.conf)|
>> (route[rs]\.example\.py)|
>> (setup_(app|exe)\.py)|
>> (splashlogo\.gif)|
>> (parameters_\d+\.py)|
>> (options_std.py)|
>> (gluon/tests/.*)|
>> (gluon/rocket\.py)|
>> (contrib/(gateways|markdown|memcache|pymysql)/.*)|
>> (contrib/(populate|taskbar_widget)\.py)|
>> (google_appengine/.*)|
>> (.*\.(bak|orig))|
>> )$
>>
>> builtins:
>> - remote_api: on
>> - appstats: on
>> - admin_redirect: on
>> - deferred: on
>>
>>
>>
>> Here's my *gaehandler.py*:
>>
>> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>>
>> """
>> This file is part of the web2py Web Framework
>> Copyrighted by Massimo Di Pierro <[email protected] <javascript:>>
>> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
>> """
>>
>> ##############################################################################
>> # Configuration parameters for Google App Engine
>> ##############################################################################
>> LOG_STATS = False # web2py level log statistics
>> APPSTATS = True # GAE level usage statistics and profiling
>> DEBUG = False # debug mode
>> #
>> # Read more about APPSTATS here
>> #
>> http://googleappengine.blogspot.com/2010/03/easy-performance-profiling-with.html
>> # can be accessed from:
>> # http://localhost:8080/_ah/stats
>> ##############################################################################
>> # All tricks in this file developed by Robin Bhattacharyya
>> ##############################################################################
>>
>>
>> import time
>> import os
>> import sys
>> import logging
>> import cPickle
>> import pickle
>> import wsgiref.handlers
>> import datetime
>>
>> path = os.path.dirname(os.path.abspath(__file__))
>>
>> # os.chdir(path) ?
>>
>> if not os.path.isdir('applications'):
>> raise RuntimeError('Running from the wrong folder')
>>
>> sys.path = [path] + [p for p in sys.path if not p == path]
>>
>> sys.modules['cPickle'] = sys.modules['pickle']
>>
>>
>> from gluon.settings import global_settings
>> from google.appengine.ext import webapp
>> from google.appengine.ext.webapp.util import run_wsgi_app
>>
>>
>> global_settings.web2py_runtime_gae = True
>> global_settings.db_sessions = True
>> if os.environ.get('SERVER_SOFTWARE', '').startswith('Devel'):
>> (global_settings.web2py_runtime, DEBUG) = \
>> ('gae:development', True)
>> else:
>> (global_settings.web2py_runtime, DEBUG) = \
>> ('gae:production', False)
>>
>>
>> import gluon.main
>>
>>
>> def log_stats(fun):
>> """Function that will act as a decorator to make logging"""
>> def newfun(env, res):
>> """Log the execution time of the passed function"""
>> timer = lambda t: (t.time(), t.clock())
>> (t0, c0) = timer(time)
>> executed_function = fun(env, res)
>> (t1, c1) = timer(time)
>> log_info = """**** Request: %.2fms/%.2fms (real time/cpu time)"""
>> log_info = log_info % ((t1 - t0) * 1000, (c1 - c0) * 1000)
>> logging.info(log_info)
>> return executed_function
>> return newfun
>>
>>
>> logging.basicConfig(level=logging.INFO)
>>
>>
>> def wsgiapp(env, res):
>> """Return the wsgiapp"""
>> env['PATH_INFO'] = env['PATH_INFO'].decode('latin1').encode('utf8')
>>
>> #when using the blobstore image uploader GAE dev SDK passes these as
>> unicode
>> # they should be regular strings as they are parts of URLs
>> env['wsgi.url_scheme'] = str(env['wsgi.url_scheme'])
>> env['QUERY_STRING'] = str(env['QUERY_STRING'])
>> env['SERVER_NAME'] = str(env['SERVER_NAME'])
>>
>> #this deals with a problem where GAE development server seems to forget
>> # the path between requests
>> if global_settings.web2py_runtime == 'gae:development':
>> gluon.admin.create_missing_folders()
>>
>> web2py_path = global_settings.applications_parent # backward
>> compatibility
>>
>> return gluon.main.wsgibase(env, res)
>>
>>
>> if LOG_STATS or DEBUG:
>> wsgiapp = log_stats(wsgiapp)
>>
>>
>> def main():
>> """Run the wsgi app"""
>> run_wsgi_app(wsgiapp)
>>
>> if __name__ == '__main__':
>> main()
>>
>>
>>
>>
>> And here's *main.py* (generated by PyCharm):
>>
>> #!/usr/bin/env python
>> #
>> # Copyright 2007 Google Inc.
>> #
>> # Licensed under the Apache License, Version 2.0 (the "License");
>> # you may not use this file except in compliance with the License.
>> # You may obtain a copy of the License at
>> #
>> # http://www.apache.org/licenses/LICENSE-2.0
>> #
>> # Unless required by applicable law or agreed to in writing, software
>> # distributed under the License is distributed on an "AS IS" BASIS,
>> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>> # See the License for the specific language governing permissions and
>> # limitations under the License.
>> #
>> import webapp2
>>
>> class MainHandler(webapp2.RequestHandler):
>> def get(self):
>> self.response.write('Hello world!')
>>
>> app = webapp2.WSGIApplication([
>> ('/', MainHandler)
>> ], debug=True)
>>
>>
>>
>> Any help would be greatly appreciated! I need this deployed by Wednesday
>> (12/9)
>>
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.