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


Python Directory.create_user方法代码示例

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


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

示例1: do_generate_users

# 需要导入模块: import Directory [as 别名]
# 或者: from Directory import create_user [as 别名]
 def do_generate_users(self, request):
   '''Automatically generates users'''
   try:
     name = request.getvalue('name', '')
     assert name != ''
     start = int(request.getvalue('start', 'error'))
     end = int(request.getvalue('end', 'error'))
     passlen = int(request.getvalue('passlength', 'error'))
   except:
     request.writeln('<p align="center"><font color="red">Error: Some fields were not entered correctly or were blank; autogeneration cancelled.</font></p>')
     return
   rand = random.Random()
   index_len = len(str(end))
   for i in range(start, end + 1):
     user = Directory.create_user(request.session.user.id)
     newname = name
     for j in range(len(str(i)), index_len):  # pad lower numbers with zeros
       newname += '0'
     newname += str(i)
     user.name = newname
     user.email = ''
     user.username = newname
     user.password = ''
     if passlen > 0:
       for i in range(passlen - 1):  # all letters except last char is a number
         user.password += rand.choice(ASCII_CHARS)
       user.password += rand.choice(DIGIT_CHARS)
     user.save()
开发者ID:ssaltzman,项目名称:POET,代码行数:30,代码来源:Administrator.py

示例2: save_user

# 需要导入模块: import Directory [as 别名]
# 或者: from Directory import create_user [as 别名]
 def save_user(self, request):
   '''Saves (or creates) a user'''
   userid = request.getvalue('userid', 'New')
   if (userid == 'New'):
     user = Directory.create_user(request.session.user.id)
   else:
     user = Directory.get_user(userid)
   for key in Directory.USER_FIELDS:
     setattr(user, key, request.getvalue(key, ''))
   user.save()
开发者ID:ssaltzman,项目名称:POET,代码行数:12,代码来源:Administrator.py


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