本文整理汇总了Python中models.users.Users.create方法的典型用法代码示例。如果您正苦于以下问题:Python Users.create方法的具体用法?Python Users.create怎么用?Python Users.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.users.Users
的用法示例。
在下文中一共展示了Users.create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import create [as 别名]
def save(self):
userInput = self.getInput()
# 只有admin才能新增用户
if not self.isAdmin():
return self.error(msg = '权限不足!', url=self.makeUrl('/admin/users/list'))
thumbnail_id = int(userInput['thumbnail']) if userInput.has_key('thumbnail') else 0
if thumbnail_id:
thumbnail_data = Images.get(Images.id == thumbnail_id).thumbnail
else:
import base64
from imaging import imaging
thumbnail_data = base64.b64encode(buffer(imaging.default_thumbnail()))
try:
Users.create(
cellphone = userInput['cellphone'],
email = userInput['email'],
name = userInput['name'],
password = hashlib.md5(userInput['passwd']).hexdigest(),
avatur = thumbnail_data,
gender = int(userInput['gender']),
description = userInput['desc'],
role = int(userInput['role'])
)
except Exception, e:
return self.error(msg = '会员保存失败: %s' % e, url=self.makeUrl('/admin/users/list'))
示例2: __init__
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import create [as 别名]
def __init__(self):
db.connect()
self.version = None
self.admin = None
self.sys_category = None
self.default_thumbnail = None
self.sys_image = None
if not Version.table_exists():
tables = [
Version,
Categories,
Products,
News,
Notifications,
Images,
Orders,
OrderDetails,
Users,
Contacts,
Accountings,
AccountIncommings,
AccountOutgoings,
Questions,
Answers,
Albums
]
db.create_tables(tables)
self.version=Version.create(description=open('VERSION').read())
self.default_thumbnail = base64.b64encode(buffer(imaging.default_thumbnail()))
self.sys_category = Categories.create(
name = '系统预置分类',
description = '预置的初始父类!',
)
self.sys_image = Images.create(
description = '预置的系统图片!',
thumbnail = self.default_thumbnail,
uuid = 'default'
)
self.admin = Users.create(
name = 'admin',
cellphone = '13912345678',
email = '[email protected]',
password = '21232f297a57a5a743894a0e4a801fc3',
gender = 0,
avatur = self.sys_image,
description = '系统管理员',
weixin= '0',
address= 'sv',
)
示例3: save
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import create [as 别名]
def save(self):
userInput = self.getInput()
# 只有admin才能新增用户
if not self.isAdmin():
return self.error(msg = '权限不足!', url=self.makeUrl('/admin/users/list'))
thumbnail_id = int(userInput['thumbnail']) if userInput.has_key('thumbnail') else 0
try:
Users.create(
cellphone = userInput['cellphone'],
email = userInput['email'],
name = userInput['name'],
password = hashlib.md5(userInput['password']).hexdigest(),
avatur = thumbnail_id,
gender = int(userInput['gender']),
description = userInput['desc'],
job = userInput['job'],
weixin = userInput['weixin'],
address = userInput['address']
)
except Exception, e:
return self.error(msg = '会员保存失败: %s' % e, url=self.makeUrl('/admin/users/list'))