OK, so I've done a clean new install and started a new app. I've
created db.py by reordering the stuff on auth from AlterEgo and fixing
a typo:
----------------------------------------------------------
# -*- coding: utf-8 -*-
##########################################################################
### This scaffolding model makes your app work on Google App Engine
too
##########################################################################
#
#try:
# from gluon.contrib.gql import * # if running on Google App
Engine
#except:
# db = SQLDB('sqlite://storage.db') # if not, use SQLite or other
DB
#else:
# db = GQLDB() # connect to Google BigTable
# session.connect(request, response, db=db) # and store sessions
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()))
db = DAL('sqlite://storage.db') # if not, use SQLite or other DB
#########################################################################
## uncomment the following line if you do not want sessions
#session.forget()
#########################################################################
########################################################################
# Define your tables below, for example
#
# >>> db.define_table('mytable',SQLField('myfield','string'))
#
# Fields can be
'string','text','password','integer','double','booelan'
# 'date','time','datetime','blob','upload', 'reference
TABLENAME'
# There is an implicit 'id integer autoincrement' field
# Consult manual for more options, validators, etc.
#
# More API examples for controllers:
#
# >>> db.mytable.insert(myfield='value')
# >>> rows=db(db.mytbale.myfield=='value).select(db.mytable.ALL)
# >>> for row in rows: print row.id, row.myfield
########################################################################
########################################################################
# Here is sample code if you need:
# - email capabilities
# - authentication (registration, login, logout, ... )
# - authorization (role based authorization)
# - crud actions
# uncomment as needed
########################################################################
from gluon.tools import Mail, Auth, Crud # new in web2py 1.56
mail=Mail() # mailer
mail.settings.server='smtp.gmail.com:587' # your SMTP server
mail.settings.sender='[email protected]' # your email
mail.settings.login='username:password' # your credentials
########################################################################
# then, to expose authentication
# http://..../[app]/default/user/login
# http://..../[app]/default/user/logout
# http://..../[app]/default/user/register
# http://..../[app]/default/user/profile
# http://..../[app]/default/user/retrieve_password
# http://..../[app]/default/user/change_password
# use the following action in controller default.py
#
# def user(): return dict(form=auth())
#
# read docs for howto create roles/groups, assign memberships and
permissions
#
# to expose CRUD
# http://..../[app]/default/data/tables
# http://..../[app]/default/data/select/[table]
# http://..../[app]/default/data/create/[table]
# http://..../[app]/default/data/read/[table]/[id]
# http://..../[app]/default/data/update/[table]/[id]
# http://..../[app]/default/data/delete/[table]/[id]
# use the following action in controller default.py
#
# def data(): return dict(form=crud())
#
# to allow automatic download of all uploaded files and enforce
authorization
# use the following action in controller default.py
#
# def download(): return response.download(request,db)
# CUSTOM USER
# instantiate auth
auth=Auth(globals(),db)
auth.define_tables() # creates all needed tables
# define custom user table
auth.settings.user = db.define_table(
auth.settings.auth_user,
db.Field('first_name', length=128, default=''),
db.Field('last_name', length=128, default=''),
db.Field('email', length=128, default='',
requires = [
IS_EMAIL(),
IS_NOT_IN_DB(db,'%s.email'%auth.settings.auth_user)
]
),
db.Field('password', 'password', readable=False,
label='Password', requires=CRYPT()),
db.Field('registration_key', length=128,
writable=False, readable=False, default=''),
)
# define any other requires tableauth.define_tables()
auth.settings.captcha=Recaptcha
(request,public_key='RECAPTCHA_PUBLIC_KEY',private_key='RECAPTCHA_PRIVATE_KEY')
auth.settings.mailer=mail # for user email verification
crud=Crud(globals(),db) # for CRUD helpers using auth
crud.settings.auth=auth # (optional) enforces authorization on
crud
----------------------------------------------------------
I've also created a default.py that contains the defs for user, data,
and download:
----------------------------------------------------------
# # sample index page with internationalization (T)
def index():
response.flash = T('Welcome to web2py')
return dict(message=T('Hello World'))
# uncomment the following if you have defined "auth" and "crud" in
models
def user(): return dict(form=auth())
def data(): return dict(form=crud())
def download(): return response.download(request,db)
# tip: use @auth.requires_login, requires_membership,
requires_permission
----------------------------------------------------------
I run the app and get the following ticket:
Traceback (most recent call last):
File "gluon/restricted.py", line 176, in restricted File "C:/web2py/
applications/myapp/models/db.py", line 105, in <module>
File "gluon/sql.py", line 986, in define_table
File "gluon/sql.py", line 438, in cleanupType
Error: expected string or buffer
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---