當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。