fixed partially problem with web2py_filesystem on GAE
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.9.6-stable+timestamp.2014.09.03.10.52.25
|
Version 2.9.6-stable+timestamp.2014.09.03.16.28.59
|
||||||
|
|||||||
+14
-7
@@ -4592,19 +4592,23 @@ class DatabaseStoredFile:
|
|||||||
def escape(self, obj):
|
def escape(self, obj):
|
||||||
return self.db._adapter.escape(obj)
|
return self.db._adapter.escape(obj)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def try_create_web2py_filesystem(db):
|
||||||
|
if not DatabaseStoredFile.web2py_filesystem:
|
||||||
|
if db._adapter.dbengine == 'mysql':
|
||||||
|
sql = "CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content LONGTEXT, PRIMARY KEY(path) ) ENGINE=InnoDB;"
|
||||||
|
elif db._adapter.dbengine in ('postgres', 'sqlite'):
|
||||||
|
sql = "CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content TEXT, PRIMARY KEY(path));"
|
||||||
|
db.executesql(sql)
|
||||||
|
DatabaseStoredFile.web2py_filesystem = True
|
||||||
|
|
||||||
def __init__(self, db, filename, mode):
|
def __init__(self, db, filename, mode):
|
||||||
if not db._adapter.dbengine in ('mysql', 'postgres', 'sqlite'):
|
if not db._adapter.dbengine in ('mysql', 'postgres', 'sqlite'):
|
||||||
raise RuntimeError("only MySQL/Postgres/SQLite can store metadata .table files in database for now")
|
raise RuntimeError("only MySQL/Postgres/SQLite can store metadata .table files in database for now")
|
||||||
self.db = db
|
self.db = db
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
if not self.web2py_filesystem:
|
DatabaseStoredFile.try_create_web2py_filesystem(db)
|
||||||
if db._adapter.dbengine == 'mysql':
|
|
||||||
sql = "CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content LONGTEXT, PRIMARY KEY(path) ) ENGINE=InnoDB;"
|
|
||||||
elif db._adapter.dbengine in ('postgres', 'sqlite'):
|
|
||||||
sql = "CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content TEXT, PRIMARY KEY(path));"
|
|
||||||
self.db.executesql(sql)
|
|
||||||
DatabaseStoredFile.web2py_filesystem = True
|
|
||||||
self.p = 0
|
self.p = 0
|
||||||
self.data = ''
|
self.data = ''
|
||||||
if mode in ('r', 'rw', 'a'):
|
if mode in ('r', 'rw', 'a'):
|
||||||
@@ -4655,6 +4659,9 @@ class DatabaseStoredFile:
|
|||||||
def exists(db, filename):
|
def exists(db, filename):
|
||||||
if exists(filename):
|
if exists(filename):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
DatabaseStoredFile.try_create_web2py_filesystem(db)
|
||||||
|
|
||||||
query = "SELECT path FROM web2py_filesystem WHERE path='%s'" % filename
|
query = "SELECT path FROM web2py_filesystem WHERE path='%s'" % filename
|
||||||
try:
|
try:
|
||||||
if db.executesql(query):
|
if db.executesql(query):
|
||||||
|
|||||||
Reference in New Issue
Block a user