added heroku support
This commit is contained in:
@@ -43,6 +43,8 @@ src:
|
|||||||
rm -f applications/admin/uploads/*
|
rm -f applications/admin/uploads/*
|
||||||
rm -f applications/welcome/uploads/*
|
rm -f applications/welcome/uploads/*
|
||||||
rm -f applications/examples/uploads/*
|
rm -f applications/examples/uploads/*
|
||||||
|
### make epydoc
|
||||||
|
make epydoc
|
||||||
### make welcome layout and appadmin the default
|
### make welcome layout and appadmin the default
|
||||||
cp applications/welcome/views/appadmin.html applications/admin/views
|
cp applications/welcome/views/appadmin.html applications/admin/views
|
||||||
cp applications/welcome/views/appadmin.html applications/examples/views
|
cp applications/welcome/views/appadmin.html applications/examples/views
|
||||||
@@ -54,7 +56,6 @@ src:
|
|||||||
cd ..; zip -r web2py/web2py_src.zip web2py/gluon/*.py web2py/gluon/contrib/* web2py/splashlogo.gif web2py/*.py web2py/README.markdown web2py/LICENSE web2py/CHANGELOG web2py/NEWINSTALL web2py/VERSION web2py/Makefile web2py/epydoc.css web2py/epydoc.conf web2py/app.example.yaml web2py/logging.example.conf web2py_exe.conf web2py/queue.example.yaml MANIFEST.in w2p_apps w2p_clone w2p_run startweb2py web2py/scripts/*.sh web2py/scripts/*.py web2py/applications/admin web2py/applications/examples/ web2py/applications/welcome web2py/applications/__init__.py web2py/site-packages/__init__.py web2py/gluon/tests/*.sh web2py/gluon/tests/*.py
|
cd ..; zip -r web2py/web2py_src.zip web2py/gluon/*.py web2py/gluon/contrib/* web2py/splashlogo.gif web2py/*.py web2py/README.markdown web2py/LICENSE web2py/CHANGELOG web2py/NEWINSTALL web2py/VERSION web2py/Makefile web2py/epydoc.css web2py/epydoc.conf web2py/app.example.yaml web2py/logging.example.conf web2py_exe.conf web2py/queue.example.yaml MANIFEST.in w2p_apps w2p_clone w2p_run startweb2py web2py/scripts/*.sh web2py/scripts/*.py web2py/applications/admin web2py/applications/examples/ web2py/applications/welcome web2py/applications/__init__.py web2py/site-packages/__init__.py web2py/gluon/tests/*.sh web2py/gluon/tests/*.py
|
||||||
|
|
||||||
mdp:
|
mdp:
|
||||||
make epydoc
|
|
||||||
make src
|
make src
|
||||||
make app
|
make app
|
||||||
make win
|
make win
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
Version 2.2.1 (2012-11-17 13:28:42) stable
|
Version 2.2.1 (2012-11-17 21:37:46) stable
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
"""
|
||||||
|
Usage: in web2py models/db.py
|
||||||
|
|
||||||
|
from gluon.contrib.heroku import get_db
|
||||||
|
db = get_db()
|
||||||
|
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
from gluon import *
|
||||||
|
from gluon.dal import ADAPTERS, UseDatabaseStoredFile,PostgreSQLAdapter
|
||||||
|
|
||||||
|
class HerokuPostgresAdapter(UseDatabaseStoredFile,PostgreSQLAdapter):
|
||||||
|
drivers = ('psycopg2',)
|
||||||
|
uploads_in_blob = True
|
||||||
|
|
||||||
|
ADAPTERS['postgres'] = HerokuPostgresAdapter
|
||||||
|
|
||||||
|
def get_db(name = None, pool_size=10):
|
||||||
|
if not name:
|
||||||
|
names = [n for n in os.environ.keys()
|
||||||
|
if n[:18]+n[-4:]=='HEROKU_POSTGRESQL__URL']
|
||||||
|
if names:
|
||||||
|
name = names[0]
|
||||||
|
if name:
|
||||||
|
db = DAL(os.environ[name], pool_size=pool_size)
|
||||||
|
current.session.connect(current.request, current.response, db=db)
|
||||||
|
else:
|
||||||
|
db = DAL('sqlite://heroku.test.sqlite')
|
||||||
|
return db
|
||||||
+7
-3
@@ -3964,13 +3964,17 @@ class DatabaseStoredFile:
|
|||||||
return self.db._adapter.escape(obj)
|
return self.db._adapter.escape(obj)
|
||||||
|
|
||||||
def __init__(self,db,filename,mode):
|
def __init__(self,db,filename,mode):
|
||||||
if db._adapter.dbengine != 'mysql':
|
if not db._adapter.dbengine in ('mysql', 'postgres'):
|
||||||
raise RuntimeError("only MySQL can store metadata .table files in database for now")
|
raise RuntimeError("only MySQL/Postgres 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:
|
if not self.web2py_filesystem:
|
||||||
self.db.executesql("CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content LONGTEXT, PRIMARY KEY(path) ) ENGINE=InnoDB;")
|
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 == 'postgres':
|
||||||
|
sql = "CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content TEXT, PRIMARY KEY(path));"
|
||||||
|
self.db.executesql(sql)
|
||||||
DatabaseStoredFile.web2py_filesystem = True
|
DatabaseStoredFile.web2py_filesystem = True
|
||||||
self.p=0
|
self.p=0
|
||||||
self.data = ''
|
self.data = ''
|
||||||
|
|||||||
Reference in New Issue
Block a user