示例#1
0
## (optional) static assets folder versioning
# response.static_version = '0.0.0'
#########################################################################
## Here is sample code if you need for
## - email capabilities
## - authentication (registration, login, logout, ... )
## - authorization (role based authorization)
## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
## - old style crud actions
## (more options discussed in gluon/tools.py)
#########################################################################

from gluon.tools import Auth, Service, PluginManager

auth = Auth(db)
service = Service()
plugins = PluginManager()

auth.settings.create_user_groups = None
auth.settings.extra_fields['auth_user'] = [
    Field(
        'email_ver',
        'boolean',
        default=True,
        label=PP("Mail není tajný"),
        comment=PP(
            'zaškrtni, pokud chceš dovolit zobrazování Tvé e-mailové adresy na stránkách'
        )),
    Field(
        'telefon',
        length=50,
示例#2
0
from gluon.admin import *
from gluon.fileutils import abspath, read_file, write_file
from gluon.tools import Service
from glob import glob
import shutil
import platform
import time
import base64
import os
try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

service = Service(globals())


@service.jsonrpc
def login():
    "dummy function to test credentials"
    return True


@service.jsonrpc
def list_apps():
    "list installed applications"
    regex = re.compile('^\w+$')
    apps = [f for f in os.listdir(apath(r=request)) if regex.match(f)]
    return apps

示例#3
0
文件: db.py 项目: mannuray/kehserver
## (optional) static assets folder versioning
# response.static_version = '0.0.0'
#########################################################################
## Here is sample code if you need for
## - email capabilities
## - authentication (registration, login, logout, ... )
## - authorization (role based authorization)
## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
## - old style crud actions
## (more options discussed in gluon/tools.py)
#########################################################################

from gluon.tools import Auth, Crud, Service, PluginManager, prettydate

auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()

auth.settings.extra_fields['auth_user'] = [
    Field('email'), Field('dob', 'date')
]

## create all tables needed by auth if not custom tables
auth.define_tables(username=True, signature=False)

## configure email
mail = auth.settings.mailer
mail.settings.server = 'logging' or 'smtp.gmail.com:587'
mail.settings.sender = '*****@*****.**'
mail.settings.login = '******'

## configure auth policy
示例#4
0
from gluon.tools import Service
service = Service(db)


@service.run
def mycall():
    if response:
        return 'true'
    return 'false'


def call():
    session.forget(response)
    return service()


def stripe():
    from gluon.contrib.stripe import StripeForm
    form = StripeForm(
        pk="pico",
        sk="pallino",
        amount=
        150,  # $1.5 (amount is in cents)                                                       
        description="Nothing").process()
    if form.accepted:
        payment_id = form.response['id']
        redirect(URL('thank_you'))
    elif form.errors:
        redirect(URL('pay_error'))
    return dict(form=form)
示例#5
0
文件: db.py 项目: pyslan/cursojulho12
#########################################################################
## Here is sample code if you need for
## - email capabilities
## - authentication (registration, login, logout, ... )
## - authorization (role based authorization)
## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
## - crud actions
## (more options discussed in gluon/tools.py)
#########################################################################

from gluon.tools import Mail, Auth, Crud, Service, PluginManager, prettydate
mail = Mail()  # mailer
auth = Auth(db)  # authentication/authorization
crud = Crud(db)  # for CRUD helpers using auth
service = Service()  # for json, xml, jsonrpc, xmlrpc, amfrpc
plugins = PluginManager()  # for configuring plugins

mail.settings.server = 'logging' or 'smtp.gmail.com:587'  # your SMTP server
mail.settings.sender = '*****@*****.**'  # your email
mail.settings.login = '******'  # your credentials or None

auth.settings.hmac_key = 'sha512:fb7ca7b8-7312-4fc7-98d3-8d354dfda9b3'  # before define_tables()
auth.define_tables()  # creates all needed tables
auth.settings.mailer = mail  # for user email verification
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.messages.verify_email = 'Click on the link http://' + request.env.http_host + URL(
    'default', 'user', args=['verify_email']) + '/%(key)s to verify your email'
auth.settings.reset_password_requires_verification = True
auth.messages.reset_password = '******' + request.env.http_host + URL(
示例#6
0
## (optional) static assets folder versioning
# response.static_version = '0.0.0'
#########################################################################
## Here is sample code if you need for
## - email capabilities
## - authentication (registration, login, logout, ... )
## - authorization (role based authorization)
## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
## - old style crud actions
## (more options discussed in gluon/tools.py)
#########################################################################

from gluon.tools import Auth, Service, PluginManager

auth = Auth(db)
service, plugins = Service(), PluginManager()

## create all tables needed by auth if not custom tables
auth.define_tables(username=False, signature=False, migrate=True)
auth.wiki(resolve=False, render='html')
## configure email
mail = auth.settings.mailer
mail.settings.server = 'logging' if request.is_local else 'smtp.gmail.com:587'
mail.settings.sender = '*****@*****.**'
mail.settings.login = '******'

## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
示例#7
0
文件: db.py 项目: simutool/appserver
# -------------------------------------------------------------------------
# response.static_version = '0.0.0'

# -------------------------------------------------------------------------
# Here is sample code if you need for
# - email capabilities
# - AUTHentication (registration, login, logout, ... )
# - AUTHorization (role based AUTHorization)
# - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
# - old style crud actions
# (more options discussed in gluon/tools.py)
# -------------------------------------------------------------------------

# host names must be a list of allowed host names (glob syntax allowed)
AUTH = Auth(DB, host_names=MYCONF.get('host.names'))
SERVICE = Service()
PLUGINS = PluginManager()

# -------------------------------------------------------------------------
# create all tables needed by AUTH if not custom tables
# -------------------------------------------------------------------------

# Auth Table Creation code moved to db_wizard.py
# because it contains references other tables

CRUD = Crud(DB)

CRUD.settings.auth = AUTH

# -------------------------------------------------------------------------
# configure email
示例#8
0
# Dummy code to enable code completion in IDE's. Can be removed at production apps
if 0:
    datasource = DAL()

current.datasource = datasource
current.db = db

auth = Auth(globals(), db)  # authentication/authorization
auth.settings.login_methods = [
    ldap_auth(mode='uid',
              server='ldap.unirio.br',
              base_dn='ou=people,dc=unirio,dc=br')
]

crud = Crud(globals(), db)  # for CRUD helpers using auth
service = Service(globals())  # for json, xml, jsonrpc, xmlrpc, amfrpc

# # create all tables needed by auth if not custom tables
auth.define_tables(username=True)
auth.settings.everybody_group_id = 6
auth.settings.create_user_groups = False

auth.settings.actions_disabled = [
    'register', 'retrieve_username', 'profile', 'lost_password'
]
db.auth_user.username.label = 'CPF'

db.define_table("api_request_type", Field("group_id", db.auth_group),
                Field("max_requests", "integer"),
                Field("max_entries", "integer"))