I don't understand here is my db :
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db, hmac_key=Auth.get_or_create_key())
crud, service, plugins = Crud(db), Service(), PluginManager()
db.define_table(
auth.settings.table_user_name,
Field('Surnom', length=128, default=''),
Field('email', length=128, default='', unique=True), # required
Field('password', 'password', length=512,# required
readable=False, label='Password'),
Field('Skills','list:reference SkillUser',default=None),
Field('Items','list:reference Item',default=None),
Field('registration_key', length=512,# required
writable=False, readable=False, default=''),
Field('reset_password_key', length=512,# required
writable=False, readable=False, default=''),
Field('registration_id', length=512, # required
writable=False, readable=False, default=''))

## do not forget validators
custom_auth_table = db[auth.settings.table_user_name] # get the 
custom_auth_table
custom_auth_table.Surnom.requires = \
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
custom_auth_table.password.requires = [CRYPT()]
custom_auth_table.email.requires = [
IS_EMAIL(error_message=auth.messages.invalid_email),
IS_NOT_IN_DB(db, custom_auth_table.email)]


Items is at default = none

here is my default.py :


def ensurefirstuser(Surnom, email, password):
  users = db(db.auth_user.email == email).select()
  if users:
    user_id = users[0].id
    created = False
    if settings.debug_ensure_first_user == True:
      print ('found user_id so created equals %s') % created
    return (user_id, created)

  else:
    my_crypt = CRYPT(key=auth.settings.hmac_key)
    crypt_pass = my_crypt(password)[0]    
    id_user = db.auth_user.insert(
                   Surnom=Surnom,
                   email=email,
                   password=crypt_pass,
                                   )
    created = True
    if settings.debug_ensure_first_user == True:
      print ('creating user_id')
    return (id_user, created)


def invitation():
    form=FORM("Code Invitation :", INPUT(_name='invitation'),"<Email 
:",INPUT(_name='email'),  INPUT(_type='submit'))
    if form.process(onvalidation=verif_invitation).accepted and 
 form.vars.invitation != None  :
        print "toto"
        user = 
ensurefirstuser("john_doe",form.vars.email,form.vars.invitation)
# the error is above visibly
        auth.user = Storage(auth.settings.table_user._filter_fields(user, 
id=True))
        auth.environment.session.auth = Storage(user=user, 
last_visit=request.now,
                                            
expiration=auth.settings.expiration)
        redirect(URL('inscription'))
    return dict(form=form)


but i've made the skills or the items unnecessary why does it still 
complain ?

Regards
Bussiere

Reply via email to