I think I have found when this occurs...
The first code executed in a controller during the initial setup is create 
two users, roles, memberships and other configs:

import datetime
import obies

def index():
    """
    example action using the internationalization operator T and flash
    rendered by views/default/index.html or views/generic.html
    """
    #logger.debug('pagina de inicio...')
    
    if not db(db.config).select().first():
        # Estamos ejecutando la aplicación por primera vez, no se han 
establecido datos correctos.
        # Insertaremos datos, importante crear el curso académico actual y 
establecerlo por defecto.
        # Comprobaremos que existen los roles Responsables, Profesores e 
Informaticos
        if not auth.id_group('Responsables'):
            auth.add_group('Responsables', 'Usuarios de responsabilidad')
        if not auth.id_group('Profesores'):    
            auth.add_group('Profesores', 'Usuarios profesores')
        if not auth.id_group('Informaticos'):
            auth.add_group('Informaticos', 'Usuarios administradores 
informáticos')
        if not auth.id_group('Administrativos'):
            auth.add_group('Administrativos', 'Usuarios administrativos')
            
            
        form = SQLFORM.factory(Field('Login_Administrador', 
requires=IS_NOT_EMPTY()),
                               Field('Nombre_Administrador', 
requires=IS_NOT_EMPTY()),
                               Field('Apellidos_Administrador', 
requires=IS_NOT_EMPTY()),
                               Field('Login_Administrativo', 
requires=IS_NOT_EMPTY()),
                               Field('Nombre_Administrativo', 
requires=IS_NOT_EMPTY()),
                               Field('Apellidos_Administrativo', 
requires=IS_NOT_EMPTY()),
                               Field('Codigo_Centro', 
requires=IS_NOT_EMPTY()),
                               Field('Nombre_Centro', 
requires=IS_NOT_EMPTY()),
                               Field('Director_Centro', 
requires=IS_NOT_EMPTY()),
                               Field('Curso_a_crear', 
requires=IS_NOT_EMPTY()),
                               Field('Retrasos_por_trimestres', 'boolean', 
default=True,requires=IS_NOT_EMPTY()),
                               Field('Retrasos_para_amonestacion', 
'integer', default=2,requires=IS_NOT_EMPTY()),
                               Field('Fecha_Inicio_1_Trimestre', 
type='date',widget=date_widget,requires=[IS_NOT_EMPTY(),IS_DATE(format=T('%d/%m/%Y'))]),
                               Field('Fecha_Fin_1_Trimestre', 
type='date',widget=date_widget,requires=[IS_NOT_EMPTY(),IS_DATE(format=T('%d/%m/%Y'))]),
                               Field('Fecha_Inicio_2_Trimestre', 
type='date',widget=date_widget,requires=[IS_NOT_EMPTY(),IS_DATE(format=T('%d/%m/%Y'))]),
                               Field('Fecha_Fin_2_Trimestre', 
type='date',widget=date_widget,requires=[IS_NOT_EMPTY(),IS_DATE(format=T('%d/%m/%Y'))]),
                               Field('Fecha_Inicio_3_Trimestre', 
type='date',widget=date_widget,requires=[IS_NOT_EMPTY(),IS_DATE(format=T('%d/%m/%Y'))]),
                               Field('Fecha_Fin_3_Trimestre', 
type='date',widget=date_widget,requires=[IS_NOT_EMPTY(),IS_DATE(format=T('%d/%m/%Y'))]))
                    
        if form.process().accepted:

            # Procesaremos el usuario administrador informático
            informatico = 
db.auth_user.insert(username=form.vars.Login_Administrador, 
first_name=form.vars.Nombre_Administrador, 
last_name=form.vars.Apellidos_Administrador)
            auth.add_membership(role='Responsables', user_id = informatico)
            auth.add_membership(role='Informaticos', user_id = informatico)

            # Procesaremos el usuario administrativo
            administrativo = 
db.auth_user.insert(username=form.vars.Login_Administrativo, 
first_name=form.vars.Nombre_Administrativo, 
last_name=form.vars.Apellidos_Administrativo)
            auth.add_membership(role='Administrativos', user_id = 
administrativo)           
            
            # Procesemos la configuración inicial del sistema
            db.curso_academico.insert(curso = form.vars.Curso_a_crear,
                              
retrasos_para_amonestacion=form.vars.Retrasos_para_amonestacion,
                              
retrasos_por_trimestres=form.vars.Retrasos_por_trimestres,
                              inicio_trimestre_1 = 
form.vars.Fecha_Inicio_1_Trimestre, 
                              fin_trimestre_1 = 
form.vars.Fecha_Fin_1_Trimestre, inicio_trimestre_2 = 
form.vars.Fecha_Inicio_2_Trimestre,
                              fin_trimestre_2 = 
form.vars.Fecha_Fin_2_Trimestre, inicio_trimestre_3 = 
form.vars.Fecha_Inicio_3_Trimestre,
                              fin_trimestre_3 = 
form.vars.Fecha_Fin_3_Trimestre)
            db.config.insert(codigo_centro = form.vars.Codigo_Centro, 
nombre_centro = form.vars.Nombre_Centro, nombre_director = 
form.vars.Director_Centro,
                              curso_academico_defecto = 
db(db.curso_academico).select().first().id, 
                 )
            db.commit()
            response.flash = T('Setup success')     
            redirect(URL(c='default/user', f='login'))
        elif form.errors:
            response.flash = T('Setup errors')
        else:
            response.flash = T('Initial application setup')

        return dict(form=form, message=T('Disciplinary Management in 
secondary schools'))
    else:
        return dict(form=None, message=T('Disciplinary Management in 
secondary schools'))

...

The only login method is ldap (openldap). Login of this two users works 
well.

On another controller I execute next code, basically I programmatically 
create new users, that do not exists yet, from other table that has been 
imported from external XML, and I update some fields of auth.user table 
like first_name, and last_name. The username is also get from the other 
table. The users that has been created here are the users that hangs web2py 
when they try login, but if I login with any user that has not been created 
in that way it works well.

@auth.requires_membership(role='Responsables')
def show_responsibles():
    oprofesor = obies.Profesor(db, session)
    profesores = oprofesor.dame_profesores_curso()
    responsables = []
        
    for profesor in profesores:
        #comprobemos si el usuario existe en la tabla auth_user
        usuario = db(db.auth_user.username == 
profesor.profesor.usuario_rayuela).select(db.auth_user.ALL).first()
        if usuario:
            
db(db.auth_user.id==usuario.id).select().first().update_record(first_name=profesor.profesor.nombre,
 
last_name=profesor.profesor.apellidos)
            if auth.has_membership(role = 'Responsables', user_id = 
usuario.id):
                usu = Storage(usuario.as_dict())
                usua = db(usuario.username == 
db.profesor.usuario_rayuela).select(db.profesor.ALL).first()
                usu.idprofesor = usua.id
                responsables.append(usu)    
        else:
            #no existe usuario autentificación asociado al profesor
            id = 
db.auth_user.insert(username=profesor.profesor.usuario_rayuela, 
first_name=profesor.profesor.nombre, last_name=profesor.profesor.apellidos)
            auth.add_membership(role = 'Profesores', user_id = 
id)           
                  
    form = FORM(TABLE(TR(T('Teacher')+':', SELECT(_name='profe', 
*[OPTION(p.profesor.apellidos+', '+p.profesor.nombre, 
_value=p.profesor.usuario_rayuela) for p in profesores])),
                      TR("", INPUT(_type="submit",_value=T("Add 
responsible")))))
                      
    if form.accepts(request.vars, session):
        #debemos insertar al profesor en el grupo responsables
        usuario = 
db(db.auth_user.username==form.vars.profe).select(db.auth_user.id).first()
        if auth.has_membership(user_id=usuario, role='Responsables'):
            session.flash = T('Responsible already defined')
        else:
            auth.add_membership(role='Responsables', 
user_id=usuario)        
            session.flash = T('new responsible inserted')
        redirect(URL('show_responsibles'))                        
    return dict(form=form, responsables=responsables)






El miércoles, 23 de octubre de 2013 00:35:31 UTC+2, Massimo Di Pierro 
escribió:
>
> Can you create a minimal app to reproduce and email it to me?
>
> On Tuesday, 22 October 2013 01:54:40 UTC-5, pkomor wrote:
>>
>> I have deleted all sessions files, I have packaged the application with 
>> 2.5.1 and restored in web2py > 2.5.1, deleting session files, I have made 
>> an initial setup of the application with a new database migration, but the 
>> result is the same.
>>
>> I think the only thing that application does "abnormal", is to create the 
>> auth_user table and auth_permissions programmatically with data of other 
>> table. With this users, there is not login failure and ldap authorizes, but 
>> there is not redirection to index page and web2py hangs. When I login with 
>> a initial user created when the application is installed there is no 
>> problem...
>>
>> Thanks
>>
>> El lunes, 21 de octubre de 2013 21:23:45 UTC+2, Massimo Di Pierro 
>> escribió:
>>>
>>> Can you try delete all session files?
>>>
>>> On Monday, 21 October 2013 02:58:13 UTC-5, pkomor wrote:
>>>>
>>>> Hello. I have an application that runs fine in web2py 2.5.1, I have 
>>>> upgraded web2py, I disabled migrations and activated after (I don't have 
>>>> fields in the model without the param length), but now when I login with 
>>>> an 
>>>> user created during the initial setup application, all is fine, but when 
>>>> any other user try to login there's not redirection to the index page and 
>>>> web2py hangs, with a "top" linux command I see the python process is 
>>>> increasing more 100%. I use ldap auth and I tried debugging but I'm not 
>>>> able to know what is wrong. Thanks.
>>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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