<s> """<STR_LIT>""" <EOL> from flask import current_app <EOL> from flask . ext . script import Command , prompt , prompt_pass <EOL> from flask_security . forms import RegisterForm <EOL> from flask_security . registerable import register_user <EOL> from werkzeug . datastructures import MultiDict <EOL> from . . services import users <EOL> class CreateUserCommand ( Command ) : <EOL> """<STR_LIT>""" <EOL> def run ( self ) : <EOL> email = prompt ( '<STR_LIT>' ) <EOL> password = prompt_pass ( '<STR_LIT>' ) <EOL> password_confirm = prompt_pass ( '<STR_LIT>' ) <EOL> data = MultiDict ( dict ( email = email , password = password , password_confirm = password_confirm ) ) <EOL> form = RegisterForm ( data , csrf_enabled = False ) <EOL> if form . validate ( ) : <EOL> user = register_user ( email = email , password = password ) <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' % ( user . id , user . email ) <EOL> return <EOL> print '<STR_LIT>' <EOL> for errors in form . errors . values ( ) : <EOL> print '<STR_LIT:\n>' . join ( errors ) <EOL> class DeleteUserCommand ( Command ) : <EOL> """<STR_LIT>""" <EOL> def run ( self ) : <EOL> email = prompt ( '<STR_LIT>' ) <EOL> user = users . first ( email = email ) <EOL> if not user : <EOL> print '<STR_LIT>' <EOL> return <EOL> users . delete ( user ) <EOL> print '<STR_LIT>' <EOL> class ListUsersCommand ( Command ) : <EOL> """<STR_LIT>""" <EOL> def run ( self ) : <EOL> for u in users . all ( ) : <EOL> print '<STR_LIT>' % ( u . id , u . email ) </s>
