#NEWLINE# def register( ) : #NEWLINE# #INDENT# from uliweb.contrib.auth import create_user , login #NEWLINE# form = functions . get_form ( 'auth.RegisterForm' ) ( ) #NEWLINE# if ( request . method == 'GET' ) : #NEWLINE# #INDENT# form . next . data = request . GET . get ( 'next' , add_prefix ( '/' ) ) #NEWLINE# return { #NEWLINE# #INDENT# 'form' : form , #NEWLINE# 'msg' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# flag = form . validate ( request . params ) #NEWLINE# if flag : #NEWLINE# #INDENT# from uliweb import settings #NEWLINE# ( f , d ) = create_user ( username = form . username . data , password = form . password . data , auth_type = settings . AUTH . AUTH_TYPE_DEFAULT ) #NEWLINE# if f : #NEWLINE# #INDENT# login ( d ) #NEWLINE# next = urllib . unquote ( request . POST . get ( 'next' , add_prefix ( '/' ) ) ) #NEWLINE# return redirect ( next ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# form . errors . update ( d ) #NEWLINE# #UNINDENT# #UNINDENT# msg = ( form . errors . get ( '_' , '' ) or _ ( 'Register failed!' ) ) #NEWLINE# return { #NEWLINE# #INDENT# 'form' : form , #NEWLINE# 'msg' : str ( msg ) , #NEWLINE# #UNINDENT# }