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


Python User.species方法代码示例

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


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

示例1: register

# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import species [as 别名]
def register():
	if 'username' in session:
		flash("Cannot create new account while logged in.")
		return redirect(url_for('hello'))
	else:	
		form = RegistrationForm()
	
		if form.validate_on_submit():
			login = form.username.data
			user = dbsession.query(User).filter_by(name=login).first()
		
			if user is None:
				pw_hash = bcrypt.generate_password_hash(form.password.data)
				user = User(login, '', pw_hash)
				user.gender = form.gender.data
				user.species = form.species.data
				user.bio = form.bio.data
				user.email = form.email.data
				user.minorflag = not form.adult.data
				user.accepttos = True
				
				dbsession.add(user)
				dbsession.commit()

				flash("User Created")
				return redirect(url_for('login'))
			else:
				flash("User already exists.")
				return redirect(url_for('register'))
		
	return render_template('register.html', form=form)
开发者ID:Aerdan,项目名称:SpiderSilk,代码行数:33,代码来源:app.py

示例2: range

# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import species [as 别名]
# all users will have the password "changeme"
# which looks like this:
# $2a$12$/xOeN.4B6wQsen5TgvOAMOUVvETJ8vDC8WqhjHRF2OYGSslxMmB2O


if __name__ == '__main__':
	password = '$2a$12$/xOeN.4B6wQsen5TgvOAMOUVvETJ8vDC8WqhjHRF2OYGSslxMmB2O'

	from db import User, Story, addDefault, refresh_db, session as dbsession
	import random
	import loremipsum

	for adduser in range(1,1000):
		username = "User%s" % (adduser)
		user = User(username,'',password)
		user.species = 'Automatic'
		user.bio = 'Automatic bio'
		user.email = '[email protected]'
		user.minorflag = True
		user.accepttos =True
		dbsession.add(user)
		dbsession.commit()

	for addstories in range(1,20000):
		newstory = Story(loremipsum.generate_sentence()[2])
		newstory.text = loremipsum.generate_paragraph()[2]
		newstory.adult = True
		newstory.uid = random.randrange(1000)+1
		dbsession.add(newstory)
		dbsession.commit()
开发者ID:Aerdan,项目名称:SpiderSilk,代码行数:32,代码来源:seeddatabase.py


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