how to use ExtendedLoginForm ?

161 views
Skip to first unread message

Bruno Rocha

unread,
Nov 11, 2010, 11:06:43 PM11/11/10
to web...@googlegroups.com
Hi, I am trying to have both default login form and RPX working.

Looking for login_methods on gluon.contrib I found ExtendedLoginForm

"""
ExtendedLoginForm is used to extend normal login form in web2py with one more login method.
So user can choose the built-in login or extended login methods.
"""


then in my model:
----------------------------------------------------------------------------------------------------------------------------

from gluon.contrib.login_methods.rpx_account import RPXAccount
from gluon.contrib.login_methods.extended_login_form import ExtendedLoginForm

rpxform = RPXAccount(request, 
    api_key='thekey',
    domain='mydomain',
    url = "http://mydomain.com.br/%s/%s" % (request.application,geturl()))

extended_login_form = ExtendedLoginForm(request, auth, rpxform, signals=['token'])

auth.settings.login_form = extended_login_form

----------------------------------------------------------------------------------------------------------------------------

I got this error:
----------------------------------------------------------------------------------------------------------------------------

Version

web2py Version 1.87.3 (2010-10-13 19:44:46) 

raceback (most recent call last):
File "/home/rochacbruno/webapps/app2/web2py/gluon/restricted.py", line 188, in restricted
exec ccode in environment
File "/home/rochacbruno/webapps/app2/web2py/applications/init/models/model.py", line 61, in <module>
extended_login_form = ExtendedLoginForm(request, auth, rpxform, signals=['token'])
TypeError: __init__() got multiple values for keyword argument 'signals'


Bruno Rocha

unread,
Nov 12, 2010, 9:28:42 AM11/12/10
to web...@googlegroups.com
Well, ExtendedLoginForm is not working, but I am trying to fix it and send a patch.

By now, I am using another solution, If someone else needs the same.

to have both auth modes [built-in and RPX] just like in: http://natalanimal.com.br/init/default/user/login  and web2pyslices.com

At models after the definition of auth:
<code>
if request.vars._next:
else:

rpxform = RPXAccount(request, 
    api_key='<your api key>',
    domain='<your domain without name >',
    url = url,
    language="pt-BR",embed=True
    
    )
</code>

In the controller:

<code>
def user():
    rpx = ''
    registerurl=URL('default','user',args='register')
    if request.vars.token:
        auth.settings.login_form = rpxform
        return dict(form=auth())
    if 'login' in request.args:
        rpx = rpxform.login_form()
        html = DIV(H1('Login'),
               rpx,BR(),BR(),
               H1(A('Click to register',_href=registerurl),BR(),' or sign-up with your password:'),
               auth(),
              )
    else:
        html = auth()
           
    return dict(form=html)


</code>


That is working very well now! thanks for Nathan Freeze who helps me a lot!

If I got success fixing ExtendLoginForm I will send a patch for this.


2010/11/12 Bruno Rocha <rocha...@gmail.com>
Reply all
Reply to author
Forward
0 new messages