# -*- coding: utf-8 -*- if request.env.web2py_runtime_gae: # if running on Google App Engine db = DAL('gae') # connect to Google BigTable session.connect(request, response, db=db) # and store sessions and tickets there ### or use the following lines to store sessions in Memcache # from gluon.contrib.memdb import MEMDB # from google.appengine.api.memcache import Client # session.connect(request, response, db=MEMDB(Client()) else: # else use a normal relational database db = DAL('sqlite://storage.sqlite') # if not, use SQLite or other DB import os from gluon.tools import * auth=Auth(globals(),db) # authentication/authorization auth.settings.hmac_key='' auth.settings.table_user = db.define_table( auth.settings.table_user_name, Field('first_name', length=512,default=''), Field('last_name', length=512,default=''), Field('nickname',length=32,default='', requires=(IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'auth_user.nickname'))), Field('email', length=512,default='', requires = (IS_EMAIL(),IS_NOT_IN_DB(db,'auth_user.email'))), Field('password', 'password', readable=False, label='Password', requires=[CRYPT(auth.settings.hmac_key)]), Field('editor','boolean',default=False,writable=False), Field('last_login',default=request.now,readable=False,writable=False), Field('registration_key', length=512, writable=False, readable=False,default=''), Field('reset_password_key', length=512, writable=False, readable=False, default='', label=auth.messages.label_reset_password_key), format=lambda row: row.nickname, ) auth.define_tables() # creates all needed tables crud=Crud(globals(),db) # for CRUD helpers using auth service=Service(globals()) # for json, xml, jsonrpc, xmlrpc, amfrpc # crud.settings.auth=auth # enforces authorization on crud mail=Mail() # mailer mail.settings.server = 'localhost:25' mail.settings.sender = 'you@example.com' auth.settings.mailer=mail # for user email verification auth.settings.registration_requires_verification = True # auth.settings.registration_requires_approval = True auth.messages.verify_email = 'Click on the link http://web2py.com'+URL(r=request,c='default',f='user',args=['verify_email'])+'/%(key)s to verify your email' auth.settings.reset_password_requires_verification = True auth.messages.reset_password = 'Click on the link http://web2py.com'+URL(r=request,c='default',f='user',args=['reset_password'])+'/%(key)s to reset your password'