For IntranetWikis it could be useful to have a mechanism to create multiple UserProfiles at once. Starting base could be a text-file with a WikiName in each line, or a query to a database or LDAP server.
see also MoinMoinQuestions question "User Registration Query".
see also UserPreferencesRedesign (if profiles are always created by a script then the current UserPreferences form would not be appropriate).
Contents
Creating User Profiles
Python Script
/moin_addsubscription.py - creates one user (not tested under 1.3 yet)
I'm calling this module based on information from an LDAP server. If you would like to create multiple users from a text file etc. please tell me what format you would like. I personally don't like to put the passwords in a file; I would rather use random passwords and get the users to email themselves using the wiki itself. To make this a bit easier I've hacked my installation of moin 1.2.3 to modify the UserPreferences page (http://mirriwinni.it.jcu.edu.au/studentwiki/UserPreferences). - ChrisGaskett
Have you thought about using HTTP auth? Then you don't need to pass passwords to MoinMoin. You need mod_ldap (Apache) or any other LDAP connector for your web server, though. Hopefully, MoinMoin will be able to generate the user accounts automatically in the future when HTTP auth is used.
Other Languages
I was using an awk/sh script written by Phillip Musumeci to generate UserProfiles, but am now using the Python script above. The basic task is to create an appropriate file in the MoinMoin data/user directory, similar to those already found in that directory. - ChrisGaskett
Some notes:
User ids must match regular expression '^\d+\.\d+(\.\d+)?$' i.e. number.number[.number] (user.py)
User ids are generated with "%s.%d" % (str(time.time()), randint(0,65535)) which confirms to the regular expression above (user.py)
User ids should not be guessable, thus the random numbers above (see UserData)
Passwords can be encrypted on the command line with htpasswd -nsb
After generating new users, delete the userdict.pickle file (see UserData)
passwd for htaccess
If we are using apache htaccess for access control, we need to create the passwd-file:
import os # First create the file (option -c) os.system("htpasswd -cb passwd_new WikiMaster topsecret") # read the list and append eacht name inputfile = open("names.txt", "r") for workline in inputfile.readline(): os.system("htpasswd -b passwd_new " + name + " topsecret")
ToDo:
- create different passwords for each user
Managing Existing Users
Checking Validity
MoinMoin comes with a script, moin_usercheck-jh-new.py
Managing Subscriptions
If your users fall into natural groups, for example students enrolled in different subjects, it can be useful to have a method to subscribe them to pages in bulk (of course, they can unsubscribe themselves later). The following script is added as a subpage rather than an attachment because it could really use some improvement from someone with more knowledge of MoinMoin and/or python and I want to see the differences. - ChrisGaskett