Example #1
0
path = os.path.join(".", os.path.dirname(__file__), "../")
sys.path.append(path)

from flask import Flask, g, render_template
from flaskext.sijax import init_sijax, route

app = Flask(__name__)

# The path where you want the extension to create the needed javascript files
# DON'T put any of your files in this directory, because they'll be deleted!
app.config["SIJAX_STATIC_PATH"] = os.path.join(".", os.path.dirname(__file__), "static/js/sijax/")

# You need to point Sijax to the json2.js library if you want to support
# browsers that don't support JSON natively (like IE <= 7)
app.config["SIJAX_JSON_URI"] = "/static/js/sijax/json2.js"

init_sijax(app)


class SijaxHandler(object):
    """A container class for all Sijax handlers.

    Grouping all Sijax handler functions in a class
    (or a Python module) allows them all to be registered with
    a single line of code.
    """

    @staticmethod
    def _dump_data(obj_response, files, form_values, container_id):
        def dump_files():
Example #2
0
# Section: Flask extension imports

from flaskext.sqlalchemy import SQLAlchemy
import flask_sijax as ajax
from flaskext.mail import Mail

# #############################################################################
# Base Initialzation and Config Section

# intialize the application
base_app = Flask("__main__")

# pull in the config file and setup other config variables
base_app.config.from_pyfile("./website.conf")
base_app.config["SQLALCHEMY_DATABASE_URI"] = base_app.config["DATABASE_URI"]
base_app.config["SIJAX_JSON_URI"] = "/static/js/json2.js"
base_app.jinja_env.trim_blocks = True


# ##############################################################################
# Prepare db enviornment and mailer enviorment

db = SQLAlchemy(base_app)
mailer = Mail(base_app)

# #############################################################################
# Section: Local imports

from base.content import Content
from base.database import create_database
from base.utils.gravatar import Gravatar