Example #1
0
app.config.url_default_namespace = "main"

## language settings
app.languages = ['en', 'it']
app.language_default = 'en'
app.language_force_on_url = True
app.language_write = True

## init database and auth
from models.user import User
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, mailer=None, base_url="/account")
auth.settings.update(download_url='/download')
db.define_models([Campaign, Donation, Cost])

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

## exposing functions from controllers
from controllers import main, campaigns, donations, costs

## add esxtensions
from weppy_haml import Haml
from weppy_assets import Assets
Example #2
0
from weppy import DAL
from weppy.tools import Auth

db = DAL(app)
auth = Auth(app, db, usermodel=User)
db.define_models(Post, Comment)

@app.command('setup')
def setup():
    # create the user
    user = db.User.validate_and_insert(
        email="*****@*****.**",
        first_name="Abdul Hamid",
        last_name="Achik Lopez",
        password="******"
    )
    # create an admin group
    admins = auth.add_group("admin")
    # add user to admins group
    auth.add_membership(admins, user.id)
    db.commnit()
Example #3
0
from weppy import DAL
from weppy.tools import service

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")
app.config.url_default_namespace = "main"

## language settings
app.languages = ['en', 'it']
app.language_default = 'en'
app.language_force_on_url = True
app.language_write = True

## init database and auth
from models.user import User
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, mailer=None,
    base_url="/account"
)
auth.settings.update(download_url='/download')
db.define_models([Campaign, Donation, Cost])

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

## exposing functions from controllers
app.config.templates_auto_reload = True
app.config.db.adapter = "sqlite"
app.config.db.host = "127.0.0.1"

# Language settings
app.languages = ['en']
app.language_default = 'en'
app.language_force_on_url = True
app.language_write = True

# init database and auth
from <%= appName %>.models.user import User

# 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
)

# adding sessions and authorization handlers
from <%= appName %>.utils import get_cryptogen_string
app.route.common_handlers = [
    SessionCookieManager(get_cryptogen_string(16)),
    db.handler,
    auth.handler
]

# Extensions
from weppy_haml import Haml
app.config.Haml.set_as_default = True
Example #6
0
    default_values = {
        'user': lambda: session.auth.user.id,
        'date': lambda: request.now
    }

    validation = {
        'text': {'presence': True}
    }

    form_rw = {
        'user': False,
        'post': False,
        'date': False
    }

db = DAL(app)
auth = Auth(app, db, usermodel=User)
db.define_models(Post, Comment)
user = db.User.validate_and_insert(
    email="*****@*****.**",
    first_name="Abdul Hamid",
    last_name="Achik Lopez",
    password="******"
)
# create an admin group
admins = auth.add_group("admin")
# add user to admins group
auth.add_membership(admins, user.id)
db.commnit()

@app.command('setup')