Massimo,

Thanks fro your reply.

strange. when you say python 2.6.4 do you mean the problem is only present 
> with this version or that you have only tested it with this version of 
> python?
>

I meant web2py version 2.4.6, which I am running at the moment. I coded the 
function a while ago, in an earlier version of web2py, generating and 
mailing the password worked then.

I narrowed the problem down by setting userkeyword='testvalue', when I 
submit the form both the password inserted into auth_user and the one 
mailed are identical in this case. So, in my code  
generate_userkeyword(name,now) apparently gets called twice.

These are the functions involved:


def onvalidation_register_form(form):
    user=db(db.auth_user.nodeID==session.userNodeID).select().first()
    if user:
        form.errors.last_name='The database already contains a user for 
this node'

@auth.requires(lambda: auth.has_membership(ADMIN))
def process_register_form():
    if not len(request.args):
        redirect(URL('register'))
    else:
        
row=categoryID=subTypeID=rowset=count=organization=person=session.userNodeID=name=plural=now=username=userkeyword=\
        
form=rating=bankaccount=userID=accountID=interfaces=interface=nodenavs=None
        row=db(db.register.id==int(request.args(0))).select().first()
        if row:
            categoryID=row.categoryID
            if row.subTypeID==ST_ORGANIZATION:
                ....
            elif row.subTypeID==ST_PERSON:
                ...
            if len(name)>4:
                slice0=name[:4]
            else:
                slice0=name
            now=str(request.now.day)+str(request.now.month)
            username=str(slice0)+str(now)+str(request.now.year)[2:]
            userkeyword=generate_userkeyword(name,now)
            
form=SQLFORM.factory(db.auth_user,submit_button='Registrer',separator='',formstyle='bootstrap')
            form.vars.title=row.title
            form.vars.first_name=row.firstName
            form.vars.familyNamePreposition=row.familyNamePreposition
            form.vars.last_name=row.lastName
            form.vars.phone=row.phone
            form.vars.email=row.email
            form[0].insert(0,DIV(LABEL(H5('Gebruikersgegevens:' + 
userkeyword),_class="control-label"),_class="control-group"))
            if 
form.process(onvalidation=onvalidation_register_form,keepvalues=False).accepted:
                id=session.userNodeID
                del session.userNodeID
                ...
                
userID=db.auth_user.insert(title=row.title,first_name=row.firstName,familyNamePreposition=row.familyNamePreposition,\
                
last_name=row.lastName,shortname=username,phone=row.phone,email=row.email,username=username,password=userkeyword,nodeID=id)
                
db.auth_membership.insert(user_id=userID,group_id=PROFILEGROUPID)
                
db.auth_membership.insert(user_id=userID,group_id=ACCOUNTGROUPID)
                
db.auth_membership.insert(user_id=userID,group_id=INTERFACEGROUPID)
                
db.auth_membership.insert(user_id=userID,group_id=TEXTGROUPID)
                ....
                row.update_record(nodeID=id,repliedOn=request.now)
                
context=dict(id=id,title=row.title,familyNamePreposition=row.familyNamePreposition,\
                
lastName=row.lastName,username=username,userkeyword=userkeyword,signature=None)
                message=response.render('mail/register.html',context)
                recipient=row.email
               mail.send(to=[recipient],subject='Uw Leonexus ID voor de 
toegang tot Leonexus CMS',message=[None,message])
            elif form.errors:
                response.flash=response_flash('formerror',session)
            elif not response.flash:
                response.flash=response.flash + REQUIRED
                session.alert='alert-info'
        else:
            session.flash='De URL bevat ongeldige argumenten'
            session.alert='alert-block'
            redirect(URL('register'))
        return dict(form=form)


def generate_userkeyword(name,now):
    import random
    value=''
    ....
    return value


Kind regards,

Annet

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to