If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!


db = SQLDB("sqlite://storage.sqlite") #@DEPLOY:db = SQLDB('postgres://mydb:mys3cr3tpassword@localhost/mydb') 

# on the server side the code will be just
db = SQLDB('postgres://mydb:mys3cr3tpassword@localhost/mydb')

You may also easily add directories to be excluded in the syncing process. This works better with if you have previously transferred your SSH key so you don't have to type your password all the time.

Just edit the commented lines and put this content in a bash script:


# you should only have to edit lines with comments

SOURCE_APP="myapp_dev" # local
TARGET_APP="myapp_prod" # remote

SOURCE_APP_PATH="/whatever/path_to/web2py/applications/${SOURCE_APP}/" #change here
TARGET_APP_PATH="webapps/w2py_prod_folder_app/web2py/applications/${TARGET_APP}/" #change here 
SOURCE_APP_PATH_STATIC="/whatever/path_to/web2py/applications/${SOURCE_APP}/static/" #change here
TARGET_APP_PATH_STATIC="webapps/folder_for_static_data" #change here
TARGET_SERVER="web94.webfaction.com" # change it to your hoster's hostname
TARGET_USER="user" # replace with your user

FIND_FILTER="-type f -name \*.html -o -name \*.py"
TOKEN="`date \"+%y%m%d%H%M%S\"`_${SOURCE_APP}_${TARGET_APP}"

echo "generating processed server files…"
rm -rf ${TEMP_DIR}
mkdir -p ${TEMP_DIR}
find ${TEMP_DIR} -type f  \( -iname '*.py' -o -iname '*.html' \) -exec sed -i '' 's/.*#@DEPLOY:[[:space:]]*//g' {} \; # for Mac OS X and BSD derived
#find ${TEMP_DIR} -type f  \( -iname '*.py' -o -iname '*.html' \) -exec sed -i 's/.*#@DEPLOY:[[:space:]]*//g' {} \; # for GNU/Linux

# you shouldn't have to change anything from now on...

echo "syncing app files…"
rsync -rah --delete --progress ${TEMP_DIR} ${TARGET_USER}@${TARGET_SERVER}:${TARGET_APP_PATH} --exclude "${EXCLUDE_DIR}" --exclude "${EXCLUDE_DIR2}" --exclude "${EXCLUDE_DIR3}"

echo "syncing static files…"

Related slices

Comments (0)

Hosting graciously provided by:
Python Anywhere