LoginPage.py :  » Web-Frameworks » Webware » Webware-1.0.2 » WebKit » Admin » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Web Frameworks » Webware 
Webware » Webware 1.0.2 » WebKit » Admin » LoginPage.py
from random import randint
from time import time,localtime

from AdminPage import AdminPage


class LoginPage(AdminPage):
  """The log-in screen for the admin pages."""

  def writeContent(self):
    if self.loginDisabled():
      self.write(self.loginDisabled())
      return
    self.writeln('<div style="margin-left:auto;margin-right:auto;width:20em">'
      '<p>&nbsp;</p>')
    extra = self.request().field('extra', None)
    if extra:
      self.writeln('<p style="color:#333399">%s</p>' % self.htmlEncode(extra))
    self.writeln('''<p>Please log in to view Administration Pages.
The username is <tt>admin</tt>. The password has been set during installation and is
stored in the <tt>Application.config</tt> file in the <tt>WebKit/Configs</tt> directory.</p>
<form method="post">
<table cellpadding="4" cellspacing="4" style="background-color:#CCCCEE;border:1px solid #3333CC;width:20em">
<tr><td align="right"><label for="username">Username:</label></td>
<td><input type="text" id="username" name="username" value="admin"></td></tr>
<tr><td align="right"><label for="password">Password:</label></td>
<td><input type="password" id="password" name="password" value=""></td></tr>
<tr><td colspan="2" align="right"><input type="submit" name="login" value="Login"></td></tr>
</table>''')
    for name, value in self.request().fields().items():
      if name.lower() not in ('username', 'password', 'login', 'logout', 'loginid'):
        if type(value) != type([]):
          value = [value]
        for v in value:
          self.writeln('<input type="hidden" name="%s" value="%s">' % (name, v))
    if self.session().hasValue('loginid'):
      loginid = self.session().value('loginid')
    else:
      # Create a "unique" login id and put it in the form as well as in the session.
      # Login will only be allowed if they match.
      loginid = ''.join(map(lambda x: '%02d' % x,
          localtime(time())[:6])) + str(randint(10000, 99999))
      self.session().setValue('loginid', loginid)
    self.writeln('<input type="hidden" name="loginid" value="%s">' % loginid)
    self.writeln('</form>\n<p>&nbsp;</p></div>')
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.