diff MoinMoin/script/account/create.py @ 501:069acf15d7b3

moin account {check,create,disable} script commands imported from: moin--main--1.5--patch-505
author Thomas Waldmann <tw@waldmann-edv.de>
date Sun, 26 Mar 2006 12:23:13 +0000
parents
children 687633456631
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/script/account/create.py	Sun Mar 26 12:23:13 2006 +0000
@@ -0,0 +1,52 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - create a user account
+
+    @copyright: 2006 by MoinMoin:ThomasWaldmann
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin.script._util import MoinScript
+
+class PluginScript(MoinScript):
+    def __init__(self, argv, def_values):
+        MoinScript.__init__(self, argv, def_values)
+        self.parser.add_option(
+            "--name", metavar="NAME", dest="uname",
+            help="Set the wiki user name to NAME."
+        )
+        self.parser.add_option(
+            "--alias", metavar="ALIAS", dest="ualiasname",
+            help="Set the wiki user alias name to ALIAS (e.g. the real name if NAME is cryptic)."
+        )
+        self.parser.add_option(
+            "--email", metavar="EMAIL", dest="email",
+            help="Set the user's email address to EMAIL."
+        )
+        self.parser.add_option(
+            "--password", metavar="PASSWORD", dest="password",
+            help="Set the user's password to PASSWORD (either cleartext or {SHA1}...)."
+        )
+
+    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 self.options.email
+        if not flags_given:
+            self.parser.print_help()
+            import sys
+            sys.exit(1)
+
+        self.init_request()
+        request = self.request
+
+        from MoinMoin import user, wikiutil
+        u = user.User(request, None, self.options.uname, password=self.options.password)
+        u.email = self.options.email
+        u.aliasname = self.options.ualiasname or ''
+        print " %-20s %-25s %-35s" % (u.id, u.name, u.email),
+        u.save()
+        print "- created."
+