Author: justi9
Date: 2009-08-07 11:28:42 -0400 (Fri, 07 Aug 2009)
New Revision: 3552
Added:
mgmt/trunk/cumin/python/cumin/account/widgets.py
mgmt/trunk/cumin/python/cumin/account/widgets.strings
mgmt/trunk/cumin/python/cumin/user.py
Removed:
mgmt/trunk/cumin/python/cumin/account/main.strings
mgmt/trunk/cumin/python/cumin/account/user.py
mgmt/trunk/cumin/python/cumin/account/user.strings
Modified:
mgmt/trunk/cumin/python/cumin/account/main.py
mgmt/trunk/cumin/python/cumin/account/model.py
mgmt/trunk/cumin/python/cumin/main.py
mgmt/trunk/cumin/python/cumin/stat.py
mgmt/trunk/cumin/python/cumin/util.py
mgmt/trunk/wooly/python/wooly/forms.py
Log:
Reorganize user and account code to clean things up a little and resolve an import
conflict
Modified: mgmt/trunk/cumin/python/cumin/account/main.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/main.py 2009-08-07 10:11:31 UTC (rev 3551)
+++ mgmt/trunk/cumin/python/cumin/account/main.py 2009-08-07 15:28:42 UTC (rev 3552)
@@ -1,17 +1,8 @@
-from wooly import *
-from wooly.widgets import *
-from wooly.resources import *
-
from cumin import *
-from cumin.widgets import *
from cumin.util import *
from model import *
-from wooly import Session
-
-strings = StringCatalog(__file__)
-
class AccountModule(object):
def init(self, app):
subject = app.model.subject
@@ -19,196 +10,3 @@
self.change_password = ChangePasswordTask(app, subject)
module = AccountModule()
-
-class AccountPage(CuminPage, ModeSet):
- def __init__(self, app, name):
- super(AccountPage, self).__init__(app, name)
-
- self.account = AccountContainerView(app, "account")
- self.add_mode(self.account)
- self.set_default_frame(self.account)
-
- def render_title(self, session):
- return "MRG Account"
-
-class AccountContainerView(CuminMainView):
- def __init__(self, app, name):
- super(AccountContainerView, self).__init__(app, name)
-
- self.main = AccountFrame(app, "main")
- self.add_tab(self.main)
-
- def render_admin_href(self, session):
- return Session(self.app.main_page).marshal()
-
-class AccountFrame(CuminFrame):
- def __init__(self, app, name):
- super(AccountFrame, self).__init__(app, name)
-
- self.view = AccountView(app, "view")
- self.add_mode(self.view)
-
- def render_title(self, session):
- return "Account"
-
-class AccountView(Widget):
- def __init__(self, app, name):
- super(AccountView, self).__init__(app, name)
-
- self.add_child(self.Heading(app, "heading"))
-
- self.__tabs = TabbedModeSet(app, "tabs")
- self.add_child(self.__tabs)
-
- self.__tabs.add_tab(self.AccountTab(app, "acct"))
- #self.__tabs.add_tab(UserGridJobs(app, "jobs", None))
-
- class AccountTab(ActionSet):
- def __init__(self, app, name):
- super(AccountView.AccountTab, self).__init__(app, name)
-
- def init(self):
- # XXX deferring this, but I don't like it
- task = module.change_password
- link = TaskLink(self.app, "change_password", task, None)
- self.add_child(link)
-
- super(AccountView.AccountTab, self).init()
-
- def render_title(self, session):
- return "Account Settings"
-
- class Heading(CuminHeading):
- def render_title(self, session):
- return "Account"
-
- def render_icon_href(self, session):
- return "resource?name=pool-36.png"
-
-from cumin.grid.job import JobTab
-
-class UserGridJobs(JobTab):
- def render_title(self, session):
- return "Your Grid Jobs %s" % fmt_count(self.get_item_count(session))
-
- def render_sql_where(self, session):
- if hasattr(session, "user_session"):
- user = session.user_session.subject.name
- else:
- user = ""
- elems = list()
- elems.append("b.name like '%s%s'" % (user, "%"))
- elems.append(self.get_phase_sql(session))
- return "where %s" % " and ".join(elems)
-
- def get_sql_values(self, session):
- pass
-
- def get_visible_columns(self, session):
- return self.get_request_visible_columns(session, ["custom_group",
"scheduler"])
-
- def render_user(self, session, *args):
- if hasattr(session, "user_session"):
- return session.user_session.subject.name
-
-class LoginPage(HtmlPage):
- def __init__(self, app, name):
- super(LoginPage, self).__init__(app, name)
-
- self.html_class = LoginPage.__name__
-
- self.logout = BooleanParameter(app, "logout")
- self.add_parameter(self.logout)
-
- self.origin = self.Origin(app, "origin")
- self.add_parameter(self.origin)
-
- form = LoginForm(app, "form")
- self.add_child(form)
-
- def do_process(self, session):
- if self.logout.get(session):
- #id = session.get_cookie("session")
- session.expire_cookie("session")
-
- super(LoginPage, self).do_process(session)
-
- def render_title(self, session):
- return "Log In"
-
- class Origin(Parameter):
- def get_default(self, session):
- return Session(self.app.main_page).marshal()
-
-class LoginForm(Form):
- def __init__(self, app, name):
- super(LoginForm, self).__init__(app, name)
-
- self.__login_invalid = Attribute(app, "login_invalid")
- self.add_attribute(self.__login_invalid)
-
- self.fields = FormFieldSet(app, "fields")
- self.add_child(self.fields)
-
- self.__name = self.Name(app, "name")
- self.fields.add_field(self.__name)
- self.__name.input.size = 20
-
- self.__password = self.Password(app, "password")
- self.fields.add_field(self.__password)
- self.__password.input.size = 20
-
- self.__submit = self.Submit(app, "submit")
- self.add_child(self.__submit)
-
- def do_process(self, session):
- if self.__submit.get(session):
- name = self.__name.get(session)
- password = self.__password.get(session)
-
- errors = self.validate(session)
-
- if not errors:
- try:
- user = Subject.selectBy(name=name)[0]
- except IndexError:
- self.__login_invalid.set(session, True)
- return
-
- crypted = user.password
-
- if crypted and crypt(password, crypted) == crypted:
- # You're in!
-
- usess = UserSession(self.app, user)
- session.set_cookie("session", usess.id)
-
- url = self.page.origin.get(session)
-
- self.page.set_redirect_url(session, url)
- else:
- self.__login_invalid.set(session, True)
-
- def render_operator_link(self, session):
- email = self.app.config.operator_email
-
- if email:
- return "<a href=\"mailto:%s\">site
operator</a>" % email
- else:
- return "site operator"
-
- def render_login_invalid(self, session):
- if self.__login_invalid.get(session):
- return self.get_string("login_invalid")
-
- class Name(StringField):
- def render_title(self, session):
- return "User Name"
-
- class Password(PasswordField):
- def render_title(self, session):
- return "Password"
-
- class Submit(FormButton):
- def render_content(self, session):
- return "Submit"
Deleted: mgmt/trunk/cumin/python/cumin/account/main.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/main.strings 2009-08-07 10:11:31 UTC (rev 3551)
+++ mgmt/trunk/cumin/python/cumin/account/main.strings 2009-08-07 15:28:42 UTC (rev 3552)
@@ -1,120 +0,0 @@
-[LoginPage.css]
-body.LoginPage {
- background: #f7f7f7;
- padding: 4em;
-}
-
-[LoginForm.css]
-form.LoginForm {
- background: #fff;
- width: 16em;
- margin: 0 auto;
- border: 1px solid #ddd;
- -moz-border-radius: 0.5em;
- -webkit-border-radius: 0.5em;
- padding: 2em;
-}
-
-form.LoginForm > h1 {
- margin: 0 0 1em 0;
-}
-
-form.LoginForm h1 img {
- vertical-align: -60%;
- margin: 0 0.25em 0 0;
-}
-
-form.LoginForm input {
- width: 12em;
-}
-
-form.LoginForm input.submit {
- width: auto;
-}
-
-form.LoginForm > div.buttons {
- margin: 1.5em 0 0 0;
-}
-
-form.LoginForm p.login_invalid {
- color: red;
-}
-
-[LoginForm.html]
-<form id="{id}" class="LoginForm" method="post"
action="?">
- <h1><img src="resource?name=mrg-36.png"/> MRG
Management</h1>
-
- <p>Enter your user name and password to log in.</p>
-
- <p>If you do not have an account or have trouble logging in, contact
- the {operator_link}.</p>
-
- {login_invalid}
-
- {fields}
-
- <div class="buttons">{submit}</div>
-
- <div>{hidden_inputs}</div>
-</form>
-
-<script type="text/javascript">
- $("{id}").elements[0].focus();
-
-</script>
-
-[LoginForm.login_invalid]
-<p class="login_invalid">The user name and password you entered do not
-match any account.</p>
-
-[AccountContainerView.html]
-<div id="head">
- <div id="user">
- Hi, {user_name}
- <strong>·</strong>
- <a id="account" onclick="wooly.clearUpdates()"
href="{admin_href}">MRG Management</a>
- <strong>·</strong>
- <a id="logout" onclick="wooly.clearUpdates()"
href="{logout_href}">Log Out</a>
- </div>
-
- <img id="logo" src="resource?name=rhlogo-32.png"/>
-
-</div>
-<div id="body">
-
-<div id="messages" style="display: {action_display};"><p
title="close"
onclick="cumin.hideActions()">x</p>{actions}</div>
- {heartbeat}
-
-{content}</div>
-
-<div id="foot"/>
-
-[AccountTab.html]
-<ul class="actions">
- <li>{change_password}</li>
-</ul>
-
-[MyGridJobs.html]
-<form id="{id}" method="post" action="?">
-<div class="rfloat">{phase}</div>
-Jobs submitted by {user}
-
- <div class="sactions" style="clear:right;">
- <h2>Act on Selected Jobs:</h2>
- {hold} {release} {remove}
- </div>
-
- <table class="mobjects">
- <thead>
- <tr>
- <th class="setnav" colspan="{column_count}">
- <div class="rfloat">{page}</div>
- {count}
- </th>
- </tr>
- <tr>{headers}</tr>
- </thead>
- <tbody>{items}</tbody>
- </table>
- <div>{hidden_inputs}</div>
-</form>
Modified: mgmt/trunk/cumin/python/cumin/account/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/model.py 2009-08-07 10:11:31 UTC (rev 3551)
+++ mgmt/trunk/cumin/python/cumin/account/model.py 2009-08-07 15:28:42 UTC (rev 3552)
@@ -1,6 +1,7 @@
from cumin.model import *
+from cumin.user import *
-from user import *
+from widgets import *
class ChangePasswordTask(Task):
def __init__(self, app, cls):
Deleted: mgmt/trunk/cumin/python/cumin/account/user.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/user.py 2009-08-07 10:11:31 UTC (rev 3551)
+++ mgmt/trunk/cumin/python/cumin/account/user.py 2009-08-07 15:28:42 UTC (rev 3552)
@@ -1,65 +0,0 @@
-from wooly import *
-from wooly.widgets import *
-from wooly.resources import *
-
-from cumin.widgets import *
-from cumin.util import *
-
-strings = StringCatalog(__file__)
-
-log = logging.getLogger("cumin.user")
-
-class ChangePasswordForm(CuminFieldForm):
- def __init__(self, app, name, task):
- super(ChangePasswordForm, self).__init__(app, name)
-
- self.task = task
-
- self.__current = self.Current(app, "current")
- self.add_field(self.__current)
- self.__current.input.size = 20
-
- self.__new0 = self.New0(app, "new0")
- self.add_field(self.__new0)
- self.__new0.input.size = 20
-
- self.__new1 = self.New1(app, "new1")
- self.add_field(self.__new1)
- self.__new1.input.size = 20
-
- def process_submit(self, session):
- curr = self.__current.get(session)
- new0 = self.__new0.get(session)
- new1 = self.__new1.get(session)
-
- subject = session.user_session.subject
- crypted = subject.password
-
- if crypt_password(curr, crypted) != crypted:
- error = FormError("The password is incorrect", self.__current)
- self.errors.add(session, error)
-
- if new0 != new1:
- error = FormError("The new passwords do not match")
- self.errors.add(session, error)
-
- self.check(session)
-
- if not self.errors.get(session):
- self.task.invoke(session, subject, new0)
- self.task.exit_with_redirect(session, subject)
-
- def render_title(self, session):
- return "Change password"
-
- class Current(PasswordField):
- def render_title(self, session):
- return "Current password"
-
- class New0(PasswordField):
- def render_title(self, session):
- return "New password"
-
- class New1(PasswordField):
- def render_title(self, session):
- return "Repeat new password"
Deleted: mgmt/trunk/cumin/python/cumin/account/user.strings
===================================================================
Added: mgmt/trunk/cumin/python/cumin/account/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/widgets.py (rev 0)
+++ mgmt/trunk/cumin/python/cumin/account/widgets.py 2009-08-07 15:28:42 UTC (rev 3552)
@@ -0,0 +1,266 @@
+import logging
+
+from wooly import *
+from wooly.widgets import *
+from wooly.resources import *
+
+from cumin import *
+from cumin.user import *
+from cumin.widgets import *
+from cumin.util import *
+
+import main
+
+from wooly import Session
+
+log = logging.getLogger("cumin.account.widgets")
+
+strings = StringCatalog(__file__)
+
+class AccountPage(CuminPage, ModeSet):
+ def __init__(self, app, name):
+ super(AccountPage, self).__init__(app, name)
+
+ self.account = AccountMainView(app, "account")
+ self.add_mode(self.account)
+ self.set_default_frame(self.account)
+
+ def render_title(self, session):
+ return "MRG Account"
+
+class AccountMainView(CuminMainView):
+ def __init__(self, app, name):
+ super(AccountMainView, self).__init__(app, name)
+
+ self.main = AccountFrame(app, "main")
+ self.add_tab(self.main)
+
+ def render_admin_href(self, session):
+ return Session(self.app.main_page).marshal()
+
+class AccountFrame(CuminFrame):
+ def __init__(self, app, name):
+ super(AccountFrame, self).__init__(app, name)
+
+ self.view = AccountView(app, "view")
+ self.add_mode(self.view)
+
+ def render_title(self, session):
+ return "Account"
+
+class AccountView(Widget):
+ def __init__(self, app, name):
+ super(AccountView, self).__init__(app, name)
+
+ self.add_child(self.Heading(app, "heading"))
+
+ self.__tabs = TabbedModeSet(app, "tabs")
+ self.add_child(self.__tabs)
+
+ self.__tabs.add_tab(self.AccountTab(app, "acct"))
+ #self.__tabs.add_tab(UserGridJobs(app, "jobs", None))
+
+ class AccountTab(ActionSet):
+ def __init__(self, app, name):
+ super(AccountView.AccountTab, self).__init__(app, name)
+
+ def init(self):
+ # XXX deferring this, but I don't like it
+ task = main.module.change_password
+ link = TaskLink(self.app, "change_password", task, None)
+ self.add_child(link)
+
+ super(AccountView.AccountTab, self).init()
+
+ def render_title(self, session):
+ return "Account Settings"
+
+ class Heading(CuminHeading):
+ def render_title(self, session):
+ return "Account"
+
+ def render_icon_href(self, session):
+ return "resource?name=pool-36.png"
+
+from cumin.grid.job import JobTab
+
+class UserGridJobs(JobTab):
+ def render_title(self, session):
+ return "Your Grid Jobs %s" % fmt_count(self.get_item_count(session))
+
+ def render_sql_where(self, session):
+ if hasattr(session, "user_session"):
+ user = session.user_session.subject.name
+ else:
+ user = ""
+ elems = list()
+ elems.append("b.name like '%s%s'" % (user, "%"))
+ elems.append(self.get_phase_sql(session))
+ return "where %s" % " and ".join(elems)
+
+ def get_sql_values(self, session):
+ pass
+
+ def get_visible_columns(self, session):
+ return self.get_request_visible_columns(session, ["custom_group",
"scheduler"])
+
+ def render_user(self, session, *args):
+ if hasattr(session, "user_session"):
+ return session.user_session.subject.name
+
+class LoginPage(HtmlPage):
+ def __init__(self, app, name):
+ super(LoginPage, self).__init__(app, name)
+
+ self.html_class = LoginPage.__name__
+
+ self.logout = BooleanParameter(app, "logout")
+ self.add_parameter(self.logout)
+
+ self.origin = self.Origin(app, "origin")
+ self.add_parameter(self.origin)
+
+ form = LoginForm(app, "form")
+ self.add_child(form)
+
+ def do_process(self, session):
+ if self.logout.get(session):
+ #id = session.get_cookie("session")
+ session.expire_cookie("session")
+
+ super(LoginPage, self).do_process(session)
+
+ def render_title(self, session):
+ return "Log In"
+
+ class Origin(Parameter):
+ def get_default(self, session):
+ return Session(self.app.main_page).marshal()
+
+class LoginForm(Form):
+ def __init__(self, app, name):
+ super(LoginForm, self).__init__(app, name)
+
+ self.__login_invalid = Attribute(app, "login_invalid")
+ self.add_attribute(self.__login_invalid)
+
+ self.fields = FormFieldSet(app, "fields")
+ self.add_child(self.fields)
+
+ self.__name = self.Name(app, "name")
+ self.fields.add_field(self.__name)
+ self.__name.input.size = 20
+
+ self.__password = self.Password(app, "password")
+ self.fields.add_field(self.__password)
+ self.__password.input.size = 20
+
+ self.__submit = self.Submit(app, "submit")
+ self.add_child(self.__submit)
+
+ def do_process(self, session):
+ if self.__submit.get(session):
+ name = self.__name.get(session)
+ password = self.__password.get(session)
+
+ self.check(session)
+
+ if not self.errors.get(session):
+ try:
+ user = Subject.selectBy(name=name)[0]
+ except IndexError:
+ self.__login_invalid.set(session, True)
+ return
+
+ crypted = user.password
+
+ if crypted and crypt(password, crypted) == crypted:
+ # You're in!
+
+ usess = UserSession(self.app, user)
+ session.set_cookie("session", usess.id)
+
+ url = self.page.origin.get(session)
+
+ self.page.set_redirect_url(session, url)
+ else:
+ self.__login_invalid.set(session, True)
+
+ def render_operator_link(self, session):
+ email = self.app.config.operator_email
+
+ if email:
+ return "<a href=\"mailto:%s\">site
operator</a>" % email
+ else:
+ return "site operator"
+
+ def render_login_invalid(self, session):
+ if self.__login_invalid.get(session):
+ return self.get_string("login_invalid")
+
+ class Name(StringField):
+ def render_title(self, session):
+ return "User Name"
+
+ class Password(PasswordField):
+ def render_title(self, session):
+ return "Password"
+
+ class Submit(FormButton):
+ def render_content(self, session):
+ return "Submit"
+
+class ChangePasswordForm(CuminFieldForm):
+ def __init__(self, app, name, task):
+ super(ChangePasswordForm, self).__init__(app, name)
+
+ self.task = task
+
+ self.__current = self.Current(app, "current")
+ self.add_field(self.__current)
+ self.__current.input.size = 20
+
+ self.__new0 = self.New0(app, "new0")
+ self.add_field(self.__new0)
+ self.__new0.input.size = 20
+
+ self.__new1 = self.New1(app, "new1")
+ self.add_field(self.__new1)
+ self.__new1.input.size = 20
+
+ def process_submit(self, session):
+ curr = self.__current.get(session)
+ new0 = self.__new0.get(session)
+ new1 = self.__new1.get(session)
+
+ subject = session.user_session.subject
+ crypted = subject.password
+
+ if crypt_password(curr, crypted) != crypted:
+ error = FormError("The password is incorrect", self.__current)
+ self.errors.add(session, error)
+
+ if new0 != new1:
+ error = FormError("The new passwords do not match")
+ self.errors.add(session, error)
+
+ self.check(session)
+
+ if not self.errors.get(session):
+ self.task.invoke(session, subject, new0)
+ self.task.exit_with_redirect(session, subject)
+
+ def render_title(self, session):
+ return "Change password"
+
+ class Current(PasswordField):
+ def render_title(self, session):
+ return "Current password"
+
+ class New0(PasswordField):
+ def render_title(self, session):
+ return "New password"
+
+ class New1(PasswordField):
+ def render_title(self, session):
+ return "Repeat new password"
Added: mgmt/trunk/cumin/python/cumin/account/widgets.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/widgets.strings (rev 0)
+++ mgmt/trunk/cumin/python/cumin/account/widgets.strings 2009-08-07 15:28:42 UTC (rev
3552)
@@ -0,0 +1,120 @@
+[LoginPage.css]
+body.LoginPage {
+ background: #f7f7f7;
+ padding: 4em;
+}
+
+[LoginForm.css]
+form.LoginForm {
+ background: #fff;
+ width: 16em;
+ margin: 0 auto;
+ border: 1px solid #ddd;
+ -moz-border-radius: 0.5em;
+ -webkit-border-radius: 0.5em;
+ padding: 2em;
+}
+
+form.LoginForm > h1 {
+ margin: 0 0 1em 0;
+}
+
+form.LoginForm h1 img {
+ vertical-align: -60%;
+ margin: 0 0.25em 0 0;
+}
+
+form.LoginForm input {
+ width: 12em;
+}
+
+form.LoginForm input.submit {
+ width: auto;
+}
+
+form.LoginForm > div.buttons {
+ margin: 1.5em 0 0 0;
+}
+
+form.LoginForm p.login_invalid {
+ color: red;
+}
+
+[LoginForm.html]
+<form id="{id}" class="LoginForm" method="post"
action="?">
+ <h1><img src="resource?name=mrg-36.png"/> MRG
Management</h1>
+
+ <p>Enter your user name and password to log in.</p>
+
+ <p>If you do not have an account or have trouble logging in, contact
+ the {operator_link}.</p>
+
+ {login_invalid}
+
+ {fields}
+
+ <div class="buttons">{submit}</div>
+
+ <div>{hidden_inputs}</div>
+</form>
+
+<script type="text/javascript">
+ $("{id}").elements[0].focus();
+
+</script>
+
+[LoginForm.login_invalid]
+<p class="login_invalid">The user name and password you entered do not
+match any account.</p>
+
+[AccountMainView.html]
+<div id="head">
+ <div id="user">
+ Hi, {user_name}
+ <strong>·</strong>
+ <a id="account" onclick="wooly.clearUpdates()"
href="{admin_href}">MRG Management</a>
+ <strong>·</strong>
+ <a id="logout" onclick="wooly.clearUpdates()"
href="{logout_href}">Log Out</a>
+ </div>
+
+ <img id="logo" src="resource?name=rhlogo-32.png"/>
+
+</div>
+<div id="body">
+
+<div id="messages" style="display: {action_display};"><p
title="close"
onclick="cumin.hideActions()">x</p>{actions}</div>
+ {heartbeat}
+
+{content}</div>
+
+<div id="foot"/>
+
+[AccountTab.html]
+<ul class="actions">
+ <li>{change_password}</li>
+</ul>
+
+[MyGridJobs.html]
+<form id="{id}" method="post" action="?">
+<div class="rfloat">{phase}</div>
+Jobs submitted by {user}
+
+ <div class="sactions" style="clear:right;">
+ <h2>Act on Selected Jobs:</h2>
+ {hold} {release} {remove}
+ </div>
+
+ <table class="mobjects">
+ <thead>
+ <tr>
+ <th class="setnav" colspan="{column_count}">
+ <div class="rfloat">{page}</div>
+ {count}
+ </th>
+ </tr>
+ <tr>{headers}</tr>
+ </thead>
+ <tbody>{items}</tbody>
+ </table>
+ <div>{hidden_inputs}</div>
+</form>
Modified: mgmt/trunk/cumin/python/cumin/main.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/main.py 2009-08-07 10:11:31 UTC (rev 3551)
+++ mgmt/trunk/cumin/python/cumin/main.py 2009-08-07 15:28:42 UTC (rev 3552)
@@ -2,15 +2,11 @@
import os
import sys
-from datetime import datetime, timedelta
from mint import *
from parsley.config import Config, ConfigParameter
from parsley.loggingex import *
-from qpid.datatypes import uuid4
from stat import StatChartPage, StatStackedPage, SlotMapPage, \
StatFlashPage, FlashFullPage
-from threading import Thread, Event
-from time import sleep
from wooly import Application, Session, Page
from wooly.devel import DevelPage
from wooly.pages import ResourcePage
@@ -18,6 +14,7 @@
from config import *
from model import *
+from user import *
from widgets import *
from managementserver import *
@@ -115,41 +112,6 @@
def stop(self):
self.model.stop()
-class UserSession(object):
- def __init__(self, app, subject):
- self.app = app
- self.subject = subject
- self.id = str(uuid4())
- self.created = datetime.now()
-
- self.app.user_sessions_by_id[self.id] = self
-
- def delete(self):
- del self.app.user_sessions_by_id[self.id]
-
-class UserSessionExpireThread(Thread):
- def __init__(self, app):
- super(UserSessionExpireThread, self).__init__()
-
- self.app = app
- self.setDaemon(True)
-
- def run(self):
- while True:
- self.expire_sessions()
- sleep(60)
-
- def expire_sessions(self):
- when = datetime.now() - timedelta(hours=2)
- count = 0
-
- for session in self.app.user_sessions_by_id.values():
- if session.created < when:
- session.delete()
- count += 1
-
- log.info("Expired %i user sessions", count)
-
class MainPage(CuminPage, ModeSet):
def __init__(self, app, name):
super(MainPage, self).__init__(app, name)
Modified: mgmt/trunk/cumin/python/cumin/stat.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.py 2009-08-07 10:11:31 UTC (rev 3551)
+++ mgmt/trunk/cumin/python/cumin/stat.py 2009-08-07 15:28:42 UTC (rev 3552)
@@ -1,16 +1,15 @@
-from wooly import *
-from wooly.widgets import *
-from mint import *
+import cStringIO
+
from math import sqrt
+from mint import *
from random import randint
+from wooly import *
+from wooly.widgets import *
from widgets import *
from parameters import *
from util import *
from formats import *
-#import tempfile
-import cStringIO
-from datetime import timedelta, datetime
from OpenFlashChart import Chart, Element
@@ -552,8 +551,8 @@
samples[stat] = stat.samples(object, duration, interval, method)
# take stddev into account for max and min y values
- deviated_values = [(nvl(x[1],0) + float(nvl(x[2],0))/2,
- nvl(x[1],0) - float(nvl(x[2],0))/2)
+ deviated_values = [(nvl(x[1],0) + float(nvl(x[2],0))/2,
+ nvl(x[1],0) - float(nvl(x[2],0))/2)
for x in samples[stat] for stat in stats]
max_value = deviated_values and max(max(deviated_values)) or 1
min_value = deviated_values and min(min(deviated_values)) or 0
@@ -745,7 +744,7 @@
animation.type = "bounce"
animation.distance = 8
element.animate.append(animation)
-
+
element.tip = "#percent# (Click to modify)"
element.colours = self.colors
element.on_click = "ofc_change_priority"
@@ -759,7 +758,7 @@
{"value": 6, "label": "Reporting"},
{"value": 9, "label": "Management"}
]
-
+
chart.elements.append(element)
return chart.create()
@@ -873,9 +872,9 @@
max_of_axiis = max(max_value, axis_for_vals)
# the most recent value(s) changed the y-axis range
if axis_max != max_of_axiis:
- samples = self.fetch_samples(object, time_span, interval,
- self.fix_method(method, mode),
- mode, False, stats,
+ samples = self.fetch_samples(object, time_span, interval,
+ self.fix_method(method, mode),
+ mode, False, stats,
end_seconds_ago=end_seconds_ago)
max_value, min_value = self.get_max_min(session, stats, samples)
else:
Added: mgmt/trunk/cumin/python/cumin/user.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/user.py (rev 0)
+++ mgmt/trunk/cumin/python/cumin/user.py 2009-08-07 15:28:42 UTC (rev 3552)
@@ -0,0 +1,38 @@
+from util import *
+
+log = logging.getLogger("cumin.user")
+
+class UserSession(object):
+ def __init__(self, app, subject):
+ self.app = app
+ self.subject = subject
+ self.id = str(uuid4())
+ self.created = datetime.now()
+
+ self.app.user_sessions_by_id[self.id] = self
+
+ def delete(self):
+ del self.app.user_sessions_by_id[self.id]
+
+class UserSessionExpireThread(Thread):
+ def __init__(self, app):
+ super(UserSessionExpireThread, self).__init__()
+
+ self.app = app
+ self.setDaemon(True)
+
+ def run(self):
+ while True:
+ self.expire_sessions()
+ sleep(60)
+
+ def expire_sessions(self):
+ when = datetime.now() - timedelta(hours=2)
+ count = 0
+
+ for session in self.app.user_sessions_by_id.values():
+ if session.created < when:
+ session.delete()
+ count += 1
+
+ log.info("Expired %i user sessions", count)
Modified: mgmt/trunk/cumin/python/cumin/util.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/util.py 2009-08-07 10:11:31 UTC (rev 3551)
+++ mgmt/trunk/cumin/python/cumin/util.py 2009-08-07 15:28:42 UTC (rev 3552)
@@ -1,11 +1,15 @@
import sys
+import os
+import logging
+
+from crypt import crypt
from datetime import datetime, timedelta
-from logging import getLogger
+from qpid.datatypes import uuid4
+from random import randint
+from random import sample
+from threading import Thread, Event
from time import mktime, time, sleep
-from random import randint
from xml.sax.saxutils import escape as xml_escape
-from crypt import crypt
-from random import sample
def short_id():
return "%08x" % randint(0, sys.maxint)
Modified: mgmt/trunk/wooly/python/wooly/forms.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/forms.py 2009-08-07 10:11:31 UTC (rev 3551)
+++ mgmt/trunk/wooly/python/wooly/forms.py 2009-08-07 15:28:42 UTC (rev 3552)
@@ -21,6 +21,9 @@
def has_errors(self, session):
return len(self.errors.get(session))
+ def check(self, session):
+ pass
+
def get_origin(self, session):
origin = self.origin.get(session)
@@ -540,9 +543,6 @@
def cancel(self, session):
self.cancel_button.set(session, True)
- def check(self, session):
- pass
-
def do_process(self, session):
if self.cancel_button.get(session):
self.cancel_button.set(session, False)