コード例 #1
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

# 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.define_tables(username=False, signature=False)

# -------------------------------------------------------------------------
# configure email
# -------------------------------------------------------------------------
mail = auth.settings.mailer
mail.settings.server = 'logging' if request.is_local else myconf.get(
    'smtp.server')
mail.settings.sender = myconf.get('smtp.sender')
mail.settings.login = myconf.get('smtp.login')
コード例 #2
0
ファイル: events.py プロジェクト: jjacobson93/javelin-web2py
__status__ = "Development"
__data__ = {
    'name': 'events',
    'label': 'Events',
    'description': 'Manage and create events',
    'icon': 'calendar',
    'u-icon': u'\uf073',
    'color': 'red',
    'required': True
}

from applications.javelin.ctr_data import ctr_enabled, get_ctr_data
from applications.javelin.private.utils import flattenDict
from gluon.contrib import simplejson as json
from gluon.tools import Service
service = Service(globals())


@auth.requires_login()
@auth.requires_membership('standard')
def index():
    """Loads the index page for the 'Events' controller

	:returns: a dictionary to pass to the view with the list of modules_enabled and the active module ('events')
	"""
    return dict(ctr_enabled=ctr_enabled,
                ctr_data=get_ctr_data(),
                active_module='events')


@auth.requires_login()
コード例 #3
0
# 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)
#########################################################################
TYPE = [T('Carer'), T('Care Seeker')]
gender = [T('Male'), T('Female')]

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('Phone', 'integer', requires=IS_NOT_EMPTY()),
    Field('Age', 'integer'),
    Field('Gender',
          'string',
          requires=IS_IN_SET(gender, zero=T('--Please select--'))),
    Field('User_Type',
          'string',
          requires=IS_IN_SET(
              TYPE,
              labels=['Looking for a Care Seeker', 'Looking for a Carer'],
              zero=T('-- Why are you using this site? --'))),
    Field('MyPict', 'upload'),
    Field('AboutMe', 'text')
コード例 #4
0
    def init_service(self):
        """ Init Services """

        self.service = Service()

        return self.service
コード例 #5
0
from gluon.tools import Service
from gluon.utils import web2py_uuid

import sys
import hashlib
import ast
import ssl

from datetime import datetime
import thread

from ledpixels import *

service = Service(globals())
service_public = Service(globals())


@auth.requires_login()
def call():
    return service()


def call_public():
    return service_public()


@service_public.jsonrpc
def ledRunProgram(duration, program):
    print "ledRunProgram"
    ret = dict()
コード例 #6
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)
コード例 #7
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(
コード例 #8
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
コード例 #9
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
コード例 #10
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"))