annotate MoinMoin/script/account/create.py @ 670:687633456631

MoinMoin.script: move _util stuff to __init__
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 20 May 2006 23:40:21 +0200
parents 069acf15d7b3
children 6dd2e29acffe
rev   line source
501
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
2 """
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
3 MoinMoin - create a user account
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
4
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
5 @copyright: 2006 by MoinMoin:ThomasWaldmann
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
7 """
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
8
670
687633456631 MoinMoin.script: move _util stuff to __init__
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 501
diff changeset
9 from MoinMoin.script import MoinScript
501
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
10
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
11 class PluginScript(MoinScript):
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
12 def __init__(self, argv, def_values):
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
13 MoinScript.__init__(self, argv, def_values)
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
14 self.parser.add_option(
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
15 "--name", metavar="NAME", dest="uname",
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
16 help="Set the wiki user name to NAME."
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
17 )
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
18 self.parser.add_option(
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
19 "--alias", metavar="ALIAS", dest="ualiasname",
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
20 help="Set the wiki user alias name to ALIAS (e.g. the real name if NAME is cryptic)."
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
21 )
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
22 self.parser.add_option(
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
23 "--email", metavar="EMAIL", dest="email",
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
24 help="Set the user's email address to EMAIL."
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
25 )
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
26 self.parser.add_option(
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
27 "--password", metavar="PASSWORD", dest="password",
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
28 help="Set the user's password to PASSWORD (either cleartext or {SHA1}...)."
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
29 )
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
30
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
31 def mainloop(self):
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
32 # we don't expect non-option arguments
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
33 if len(self.args) != 0:
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
34 self.parser.error("incorrect number of arguments")
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
35
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
36 flags_given = self.options.uname and self.options.email
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
37 if not flags_given:
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
38 self.parser.print_help()
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
39 import sys
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
40 sys.exit(1)
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
41
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
42 self.init_request()
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
43 request = self.request
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
44
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
45 from MoinMoin import user, wikiutil
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
46 u = user.User(request, None, self.options.uname, password=self.options.password)
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
47 u.email = self.options.email
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
48 u.aliasname = self.options.ualiasname or ''
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
49 print " %-20s %-25s %-35s" % (u.id, u.name, u.email),
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
50 u.save()
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
51 print "- created."
069acf15d7b3 moin account {check,create,disable} script commands
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
52