Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.script.account.create.PluginScript Class Reference
Inheritance diagram for MoinMoin.script.account.create.PluginScript:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.script.account.create.PluginScript:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def mainloop
def init_request
def run
def logRuntime

Public Attributes

 request
 argv
 def_values
 parser
 args

Detailed Description

\
Purpose:
========
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=wiki.example.org/

[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 'john@smith.com'
   moin ... account create --name JohnSmith --alias JSmith --email john@smith.com

Definition at line 11 of file create.py.


Constructor & Destructor Documentation

def MoinMoin.script.account.create.PluginScript.__init__ (   self,
  argv,
  def_values 
)

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 33 of file create.py.

00033 
00034     def __init__(self, argv, def_values):
00035         MoinScript.__init__(self, argv, def_values)
00036         self.parser.add_option(
00037             "--name", metavar="NAME", dest="uname",
00038             help="Set the wiki user name to NAME."
00039         )
00040         self.parser.add_option(
00041             "--alias", metavar="ALIAS", dest="ualiasname",
00042             help="Set the wiki user alias name to ALIAS (e.g. the real name if NAME is cryptic)."
00043         )
00044         self.parser.add_option(
00045             "--email", metavar="EMAIL", dest="email",
00046             help="Set the user's email address to EMAIL."
00047         )
00048         self.parser.add_option(
00049             "--password", metavar="PASSWORD", dest="password",
00050             help="Set the user's password to PASSWORD."
00051         )


Member Function Documentation

def MoinMoin.script.MoinScript.init_request (   self) [inherited]
create request 

Definition at line 174 of file __init__.py.

00174 
00175     def init_request(self):
00176         """ create request """
00177         from MoinMoin.web.contexts import ScriptContext
00178         url = self.options.wiki_url or None
00179         self.request = ScriptContext(url, self.options.page)

Here is the caller graph for this function:

def MoinMoin.script.Script.logRuntime (   self) [inherited]
Print the total command run time. 

Definition at line 148 of file __init__.py.

00148 
00149     def logRuntime(self):
00150         """ Print the total command run time. """
00151         if self.options.show_timing:
00152             log("Needed %.3f secs." % (time.clock() - _start_time, ))
00153 

Here is the call graph for this function:

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 52 of file create.py.

00052 
00053     def mainloop(self):
00054         # we don't expect non-option arguments
00055         if len(self.args) != 0:
00056             self.parser.error("incorrect number of arguments")
00057 
00058         flags_given = self.options.uname and self.options.email
00059         if not flags_given:
00060             self.parser.print_help()
00061             import sys
00062             sys.exit(1)
00063 
00064         self.init_request()
00065         request = self.request
00066 
00067         from MoinMoin import user
00068         if user.User(request, name=self.options.uname).exists():
00069             print 'This username "%s" exists already!' % self.options.uname
00070             return
00071         # Email should be unique - see also MoinMoin.action.newaccount
00072         if self.options.email and request.cfg.user_email_unique:
00073             if user.get_by_email_address(request, self.options.email):
00074                 print 'This emailaddress "%s" belongs to someone else!' % self.options.email
00075                 return
00076         u = user.User(request, None, self.options.uname, password=self.options.password)
00077         u.email = self.options.email
00078         u.aliasname = self.options.ualiasname or ''
00079         print " %-20s %-25s %-35s" % (u.id, u.name, u.email),
00080         u.save()
00081         print "- created."

Here is the call graph for this function:

def MoinMoin.script.Script.run (   self,
  showtime = 1 
) [inherited]
Run the main function of a command. 

Definition at line 130 of file __init__.py.

00130 
00131     def run(self, showtime=1):
00132         """ Run the main function of a command. """
00133         global flag_quiet
00134         try:
00135             try:
00136                 self.options, self.args = self.parser.parse_args(self.argv)
00137                 flag_quiet = self.options.quiet
00138                 # ToDo check if we need to initialize request (self.init_request())
00139                 self.mainloop()
00140             except KeyboardInterrupt:
00141                 log("*** Interrupted by user!")
00142             except SystemExit:
00143                 showtime = 0
00144                 raise
00145         finally:
00146             if showtime:
00147                 self.logRuntime()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 135 of file __init__.py.

Definition at line 102 of file __init__.py.

Definition at line 113 of file __init__.py.

Definition at line 178 of file __init__.py.


The documentation for this class was generated from the following file: