This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cd $OPENSHIFT_REPO_DIR/app | |
python manage.py migrate | |
mkdir -p $OPENSHIFT_DATA_DIR/static | |
ln -s $OPENSHIFT_DATA_DIR/static $OPENSHIFT_REPO_DIR/wsgi/static | |
python manage.py collectstatic --noinput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application: app | |
version: 1 | |
runtime: python27 | |
api_version: 1 | |
threadsafe: yes | |
handlers: | |
- url: /favicon\.ico | |
static_files: favicon.ico | |
upload: favicon\.ico |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import cherrypy | |
now = [2014, 10, 4, 20, 45, 41, 5, 277, 0] | |
class Root(): | |
def index(self): | |
cherrypy.response.headers['Last-Modified'] = cherrypy.lib.httputil.HTTPDate(time.mktime(tuple(now))) | |
cherrypy.lib.cptools.validate_since() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this is simple way to send almost any form data to cherrypy controller | |
$(function () { | |
$( "#save" ).click(function(){ | |
var $form = $(this).closest('form'); | |
$.ajax({ | |
url: "/rest/save", | |
data: formDataToJSON($form), | |
type: 'POST', | |
contentType: 'application/json', | |
dataType: 'json', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##this is my way to import and export data to json | |
## actually not json, but dict. But you can convert json to dict very simple way: | |
## https://docs.python.org/2/library/json.html | |
class BaseExtend(object): | |
def to_dict(self): | |
d = dict() | |
for c in self.__table__.columns: | |
if isinstance(getattr(self, c.name), datetime): | |
d[c.name] = str(getattr(self, c.name)).split('.')[0] | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
using: | |
class Root(BaseController): | |
''' Cherrypy Root class | |
''' | |
@jinja_template('main_page.html') | |
def index(self, lang=''): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
import cherrypy | |
## this have to be here to work on OpenShift environment | |
try: | |
zvirtenv = os.path.join(os.environ['OPENSHIFT_PYTHON_DIR'], | |
'virtenv', 'bin', 'activate_this.py') | |
execfile(zvirtenv, dict(__file__=zvirtenv)) | |
except KeyError: |
NewerOlder