r1093@denkpolster: jan | 2008-04-05 18:54:02 +0200
correctly handle empty user lists in sysuser create * use prefix + 01 if list of users with prefix is empty (fixes #11) git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/trunk@250 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
		
							parent
							
								
									cccc6b8fe3
								
							
						
					
					
						commit
						7152902ff3
					
				
					 1 changed files with 10 additions and 6 deletions
				
			
		|  | @ -50,14 +50,18 @@ class SysuserEntity(BackendEntity): | |||
| 
 | ||||
|     def _get_next_sysusername(self): | ||||
|         prefix = config.get('sysuser', 'nameprefix') | ||||
|         self.logger.debug("looking for next user with prefix %s" % (prefix)) | ||||
|         usernames = [user.username for user in \ | ||||
|                      getenttools.find_user_by_prefix(prefix)] | ||||
|         maxid = max([int(username[len(prefix):]) for username in usernames]) | ||||
|         maxid += 2 | ||||
|         for number in range(1, maxid): | ||||
|             username = "%s%02d" % (prefix, number) | ||||
|             if not username in usernames: | ||||
|                 return username | ||||
|         if usernames: | ||||
|             maxid = max([int(username[len(prefix):]) for username in usernames]) | ||||
|             maxid += 2 | ||||
|             for number in range(1, maxid): | ||||
|                 username = "%s%02d" % (prefix, number) | ||||
|                 if not username in usernames: | ||||
|                     return username | ||||
|         else: | ||||
|             return "%s%02d" % (prefix, 1) | ||||
| 
 | ||||
|     def _get_default_sysusertype(self): | ||||
|         return 1 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue