Ejemplo n.º 1
0
        password="******"
    )
    # create an admin group
    admins = auth.add_group("admin")
    # add user to admins group
    auth.add_membership(admins, user.id)
    db.commit()


@app.command('setup')
def setup():
    setup_admin()

#: handlers
app.common_handlers = [
    SessionCookieManager('Walternate'),
    db.handler, auth.handler
]


#: exposing functions
@app.route("/")
def index():
    posts = db(Post.id > 0).select(orderby=~Post.date)
    return dict(posts=posts)


@app.route("/post/<int:pid>")
def one(pid):
    def _validate_comment(form):
        # manually set post id in comment form
        form.params.post = pid
Ejemplo n.º 2
0
app = App(__name__)
app.config.db.uri = 'sqlite://corals.db'


class Coral(Model):
    file = Field('text')
    species = Field('text')
    date = Field('text')
    score = Field('float')
    rank = Field('int')


db = DAL(app, auto_migrate=False)
app.common_handlers = [
    db.handler,
]

db.define_models(Coral)

rows = Coral.all().select()


@app.route("/")
def corals():
    return None


@app.route("/corals")
@service.json
def coraldata():
Ejemplo n.º 3
0
from models.campaign import Campaign
from models.donation import Donation
from models.cost import Cost
## init auth before passing db models due to dependencies
## on auth tables in the other models
db = DAL(app)
auth = Auth(
    app, db, usermodel=User, base_url="account"
)
auth.settings.update(download_url='/download')
db.define_models(Campaign, Donation, Cost)

## adding sessions and authorization handlers
app.common_handlers = [
    SessionCookieManager('verySecretKey'),
    db.handler,
    auth.handler
]

## add esxtensions
from weppy_haml import Haml
from weppy_assets import Assets
from weppy_bs3 import BS3
app.config.Haml.set_as_default = True
app.config.Haml.auto_reload = True
app.use_extension(Haml)
app.config.Assets.out_folder = 'gen'
app.use_extension(Assets)
app.use_extension(BS3)

## exposing functions from controllers
Ejemplo n.º 4
0
                       password="******")
    # create an admin group
    admins = auth.add_group("admin")
    # add user to admins group
    auth.add_membership(admins, user.id)
    db.commit()


@app.command('setup')
def setup():
    setup_admin()


#: handlers
app.common_handlers = [
    SessionCookieManager('Walternate'), db.handler, auth.handler
]


#: exposing functions
@app.route("/")
def index():
    posts = Post.all().select(orderby=~Post.date)
    return dict(posts=posts)


@app.route("/post/<int:pid>")
def one(pid):
    def _validate_comment(form):
        # manually set post id in comment form
        form.params.post = pid