当前位置: 首页>>代码示例>>Python>>正文


Python User.create方法代码示例

本文整理汇总了Python中User.create方法的典型用法代码示例。如果您正苦于以下问题:Python User.create方法的具体用法?Python User.create怎么用?Python User.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User的用法示例。


在下文中一共展示了User.create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register

# 需要导入模块: import User [as 别名]
# 或者: from User import create [as 别名]
def register():
    """Register new user."""
    form = RegisterForm(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        User.create(username=form.username.data, email=form.email.data, password=form.password.data, active=True)
        flash('Thank you for registering. You can now log in.', 'success')
        return redirect(url_for('public.home'))
    else:
        flash_errors(form)
    return render_template('public/register.html', form=form)
开发者ID:LindaOrtega,项目名称:cookiecutter-flask,代码行数:12,代码来源:views.py

示例2: register

# 需要导入模块: import User [as 别名]
# 或者: from User import create [as 别名]
def register():
    form = RegisterForm(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        new_user = User.create(username=form.username.data,
                               first_name=form.first_name.data,
                               last_name=form.last_name.data,
                               email=form.email.data,
                               password=form.password.data,
                               active=True)
        flash("Thank you for registering. You can now log in.", 'success')
        return redirect(url_for('public.home'))
    else:
        flash_errors(form)
    return render_extensions('public/register.html', form=form)
开发者ID:VCTLabs,项目名称:cookiecutter-flask,代码行数:16,代码来源:public.py

示例3: test_check_password

# 需要导入模块: import User [as 别名]
# 或者: from User import create [as 别名]
 def test_check_password(self):
     user = User.create(username="foo", email="[email protected]",
                 password="foobarbaz123")
     assert user.check_password('foobarbaz123') is True
     assert user.check_password("barfoobaz") is False
开发者ID:VCTLabs,项目名称:cookiecutter-flask,代码行数:7,代码来源:test_models.py

示例4: do_token_dance

# 需要导入模块: import User [as 别名]
# 或者: from User import create [as 别名]
  def do_token_dance (self, **args) :

    """
    This is the method you should call from your 'auth' handler; that
    is the URL that you tell the Flickr API Auth flow to redirect to
    once a user has authed your application (in magic Flickr land).

    It will check for a 'frob' parameter and then call the Flickr API
    and exchange it for a valid Flickr Auth token.

    If something goes wrong it will return False, otherwise it will
    redirect the user to your application's root URL (where presumably
    you are calling 'checked_logged_in').

    For example:

    class TokenFrobHandler (FlickrApp) :

      # Assume __init__ here

      def get (self):

        try :

          new_users = True
          self.do_token_dance(allow_new_users=new_users)

        except FlickrApp.FlickrAppNewUserException, e :

          self.assign('error', 'no_new_users')

        except FlickrApp.FlickrAppAPIException, e :

          self.assign('error', 'api_error')

        except FlickrApp.FlickrAppException, e :

          self.assign('error', 'app_error')
          self.assign('error_message', e)      

        except Exception, e:

          self.assign('error', 'unknown')      
          self.assign('error_message', e)

        self.display("token_dance.html")        
        return

    """

    frob = self.request.get('frob')

    if not frob or frob == '' :
      raise FlickrAppException('Missing frob!')

    extra = self.request.get('extra')
    e_params = {}

    if extra and extra != '' :
    	extra = urlparse(extra)
        e_params = dict([part.split('=') for part in extra[2].split('&')])

    crumb = urllib.unquote(e_params['crumb'])

    if not self.validate_crumb(None, 'flickrauth', crumb) :
        raise FlickrAppCrumbException('Invalid crumb')

    api_args = {'frob': frob, 'check_response' : True}

    rsp = self.api_call('flickr.auth.getToken', api_args)

    if not rsp :
        raise FlickrAppAPIException('Failed to get token')

    token = rsp['auth']['token']['_content']
    name = rsp['auth']['user']['username']
    nsid = rsp['auth']['user']['nsid']
    perms = rsp['auth']['perms']['_content']
    user_perms = self.perms_map[perms]

    user = User.get_user_by_nsid(nsid)

    if not user :
    	if args.has_key('allow_new_users') and not args['allow_new_users'] :
            raise FlickrAppNewUserException()

    if not user :

    	args = {
        'password' : self.generate_password(),
        'token' : token,
        'username' : name,
        'nsid' : nsid,
        'perms' : user_perms,
        }

        user = User.create(args)

    else :

#.........这里部分代码省略.........
开发者ID:saga,项目名称:gae-flickrapp,代码行数:103,代码来源:__init__.py

示例5: test_check_password

# 需要导入模块: import User [as 别名]
# 或者: from User import create [as 别名]
 def test_check_password(self):
     """Check password."""
     user = User.create(username='foo', email='[email protected]',
                        password='foobarbaz123')
     assert user.check_password('foobarbaz123') is True
     assert user.check_password('barfoobaz') is False
开发者ID:abdza,项目名称:cookiecutter-flask,代码行数:8,代码来源:test_models.py


注:本文中的User.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。