Attachment 'CreateAccount.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - CreateAccount Macro
   4 
   5     Syntax:
   6         [[CreateAccount]]
   7 
   8     Lot of code take from userform.py
   9     MoinMoin - userform.py
  10     @copyright: 2001-2004 by Jürgen Hermann <jh@web.de>
  11     @license: GNU GPL, see COPYING for details.
  12     
  13     MoinMoin - CreateAccount Macro
  14     @copyright: 2006 by Oliver Siemoneit
  15     @license: GNU GPL, see COPYING for details.
  16 """
  17 
  18 from MoinMoin.widget import html
  19 
  20 
  21 def make_row(table, label, cell, **kw):
  22     """ Create a row in the form table.
  23     """
  24     table.append(html.TR().extend([
  25         html.TD(**kw).extend([html.B().append(label), '   ']),
  26         html.TD().extend(cell),
  27     ]))
  28     return table
  29 
  30 def execute(macro, args):
  31     request = macro.request
  32     _ = request.getText
  33     formatter = macro.formatter
  34 
  35     # Check if user is logged in
  36     if request.user.name != "":
  37         return ''
  38 
  39     sn = request.getScriptname()
  40     pi = request.getPathinfo()
  41     action = u"%s%s" % (sn, pi)
  42     form = html.FORM(action=action)
  43     table = html.TABLE(border="0")
  44 
  45     # Add form fields
  46     for key, label, type, length, textafter in request.cfg.user_form_fields:
  47         if key in ('name', 'password', 'password2', 'email'):
  48             if key == 'password2':
  49                 table = make_row(table, _(label),
  50                                   [html.INPUT(type=type, size=length, name=key,
  51                                               value=''),
  52                                    ' ', ])
  53                
  54             else:
  55                 table = make_row(table, _(label),
  56                                   [html.INPUT(type=type, size=length, name=key,
  57                                               value=''),
  58                                    ' ', _(textafter), ])
  59     # Add buttons
  60     buttons = [ ('create', _('Create Profile')),
  61                 ('cancel', _('Cancel')),
  62     ]
  63 
  64     button_cell = []
  65     for name, label in buttons:
  66         if not name in request.cfg.user_form_remove:
  67             button_cell.extend([
  68                 html.INPUT(type="submit", name=name, value=label),
  69                 ' ',
  70             ])
  71     make_row(table,'', button_cell)
  72 
  73 
  74     # Use the user interface language and direction
  75     lang_attr = request.theme.ui_lang_attr()
  76     form.append(html.Raw('<div class="userprefs"%s>' % lang_attr))
  77     form.append(html.INPUT(type="hidden", name="action", value="userform"))
  78     form.append(table)
  79     form.append(html.Raw("</div>"))
  80    
  81     return unicode(form)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2006-12-10 20:50:46, 2.4 KB) [[attachment:CreateAccount.py]]
  • [get | view] (2006-12-10 20:50:19, 0.8 KB) [[attachment:CreateAccount.txt]]
  • [get | view] (2006-12-10 20:52:30, 1.1 KB) [[attachment:action_init_.diff]]
  • [get | view] (2006-12-10 20:51:49, 49.4 KB) [[attachment:screenshot.jpg]]
  • [get | view] (2006-12-10 20:52:09, 1.1 KB) [[attachment:userform.diff]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.