Hello and thanks for web2py!

I am trying to run a web2py app on Google App Engine using two separate 
databases, one running Google Cloud SQL to enable complex queries, and one 
using the default Google Datastore to just be really scalable. All my tests 
run nicely using SQLite locally, but when I upload to App Engine and try to 
connect, an exception is thrown saying that 'web2py_filesystem' table does 
not exist.

Here is my db setup code:
if request.env.web2py_runtime_gae:
 db = DAL('google:sql://tryggweb-dev:test-1/active')
 db_datastore = DAL('google:datastore')
 session.connect(request, response, db_datastore)
else:
 db = DAL('sqlite://storage.sqlite', pool_size=1, check_reserved=['all'], 
lazy_tables=True)
 db_datastore = DAL('sqlite://storage_datastore.sqlite', pool_size=1, 
check_reserved=['all'], lazy_tables=True)



and here is the exception call stack, as output in the Google App Engine 
log:
Traceback (most recent call last): File 
"/base/data/home/apps/s~tryggweb-dev/test.378170307681887060/gluon/restricted.py",
 
line 220, in restricted exec ccode in environment File 
"/base/data/home/apps/s~tryggweb-dev/test.378170307681887060/applications/tryggAnnons/models/db.py",
 
line 63, in <module> Field('favorites', type='list:reference ad')) File 
"/base/data/home/apps/s~tryggweb-dev/test.378170307681887060/gluon/dal.py", 
line 8224, in define_table table = 
self.lazy_define_table(tablename,*fields,**args) File 
"/base/data/home/apps/s~tryggweb-dev/test.378170307681887060/gluon/dal.py", 
line 8261, in lazy_define_table polymodel=polymodel) File 
"/base/data/home/apps/s~tryggweb-dev/test.378170307681887060/gluon/dal.py", 
line 1098, in create_table if not table._dbt or not 
self.file_exists(table._dbt): File 
"/base/data/home/apps/s~tryggweb-dev/test.378170307681887060/gluon/dal.py", 
line 4576, in file_exists return 
DatabaseStoredFile.exists(self.db,filename) File 
"/base/data/home/apps/s~tryggweb-dev/test.378170307681887060/gluon/dal.py", 
line 4560, in exists if db.executesql(query): File 
"/base/data/home/apps/s~tryggweb-dev/test.378170307681887060/gluon/dal.py", 
line 8434, in executesql adapter.execute(query) File 
"/base/data/home/apps/s~tryggweb-dev/test.378170307681887060/gluon/dal.py", 
line 4634, in execute return self.log_execute(command.decode('utf8'), *a, 
**b) File 
"/base/data/home/apps/s~tryggweb-dev/test.378170307681887060/gluon/dal.py", 
line 1963, in log_execute ret = self.cursor.execute(command, *a[1:], **b) 
File 
"/base/data/home/runtimes/python27/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py",
 
line 566, in execute self._DoExec(request) File 
"/base/data/home/runtimes/python27/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py",
 
line 446, in _DoExec response = self._conn.MakeRequest('Exec', request) 
File 
"/base/data/home/runtimes/python27/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py",
 
line 940, in MakeRequest response = self._MakeRetriableRequest(stub_method, 
request) File 
"/base/data/home/runtimes/python27/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py",
 
line 969, in _MakeRetriableRequest raise _ToDbApiException(sql_exception) 
ProgrammingError: (1146, u"Table 'active.web2py_filesystem' doesn't exist")

I have spent a lot of time googling this, and came across this very similar 
situation: https://code.google.com/p/web2py/issues/detail?id=1625

But even though that issue is marked as fixed and the proposed patch is in 
my dal.py, I get the error.

The proposed solution in the referenced issue was to to check if the error 
raised is a ProgrammingError, and then swallow that exception, like so:
        try:
            if db.executesql(query):
                return True
        except Exception, e:
            if not (db._adapter.isOperationalError(e) or
                    db._adapter.isProgrammingError(e)):
                raise
            # no web2py_filesystem found?
            tb = traceback.format_exc()
            LOGGER.error("Could not retrieve %s\n%s" % (filename, tb))


But since the error is still thrown, i added a little tracing to see that 
the isProgrammingError method really did it's job:
        try:
            if db.executesql(query):
                return True
        except Exception, e:
            if not (db._adapter.isOperationalError(e) or
                    db._adapter.isProgrammingError(e)):
                LOGGER.warning('this didnt work' +  str(type(e)))  # ADDED 
THIS LINE FOR SENSING
                raise
            # no web2py_filesystem found?
            tb = traceback.format_exc()
            LOGGER.error("Could not retrieve %s\n%s" % (filename, tb))

After deploying to GAE, and making a request the following is found in the 
log, just after the exception stack trace:
13:43:44.639
this didnt work <class 
'google.storage.speckle.python.api.rdbms.ProgrammingError'>

This means that even though the exception is a ProgrammingError, it was not 
found to be one by the db._adapter.isProgrammingError method, and is 
therefore not swallowed as the previous fix intended.

Is this due to GAE having changed the type or package of the 
ProgrammingError? 
Any suggestions on how this could be fixed?

Thank you very much for your time!

Best regards,
Mikael Brandt


-- 
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.

Reply via email to