view MoinMoin/script/account/ @ 5437:a20de9383481

fix --wiki-url examples, needs http:// now
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 16 Jan 2010 13:10:50 +0100
parents f85cd27073a9
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
MoinMoin - create a user account

@copyright: 2006 MoinMoin:ThomasWaldmann
@license: GNU GPL, see COPYING for details.

from MoinMoin.script import MoinScript

class PluginScript(MoinScript):
This tool allows you to create user accounts via a command line interface.

Detailed Instructions:
General syntax: moin [options] account create [create-options]

[options] usually should be:
    --config-dir=/path/to/my/cfg/ --wiki-url=

[create-options] see below:
    1. Verify that you have specified the right options.
       This script does no verification of email addresses or the like.

    2. To create a normal user 'JohnSmith' with an alias of 'JSmith' and an
       email of ''
       moin ... account create --name JohnSmith --alias JSmith --email

    def __init__(self, argv, def_values):
        MoinScript.__init__(self, argv, def_values)
            "--name", metavar="NAME", dest="uname",
            help="Set the wiki user name to NAME."
            "--alias", metavar="ALIAS", dest="ualiasname",
            help="Set the wiki user alias name to ALIAS (e.g. the real name if NAME is cryptic)."
            "--email", metavar="EMAIL", dest="email",
            help="Set the user's email address to EMAIL."
            "--password", metavar="PASSWORD", dest="password",
            help="Set the user's password to PASSWORD."

    def mainloop(self):
        # we don't expect non-option arguments
        if len(self.args) != 0:
            self.parser.error("incorrect number of arguments")

        flags_given = self.options.uname and
        if not flags_given:
            import sys

        request = self.request

        from MoinMoin import user
        if user.User(request, name=self.options.uname).exists():
            print 'This username "%s" exists already!' % self.options.uname
        # Email should be unique - see also MoinMoin.action.newaccount
        if and request.cfg.user_email_unique:
            if user.get_by_email_address(request,
                print 'This emailaddress "%s" belongs to someone else!' %
        u = user.User(request, None, self.options.uname, password=self.options.password) =
        u.aliasname = self.options.ualiasname or ''
        print " %-20s %-25s %-35s" % (,,,
        print "- created."