Author: justi9
Date: 2009-08-05 09:50:07 -0400 (Wed, 05 Aug 2009)
New Revision: 3543
Modified:
mgmt/trunk/cumin/python/cumin/model.py
Log:
* Add logging for task events
* Check that we have a user_session before accessing it for a task
invocation
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2009-08-05 13:45:25 UTC (rev 3542)
+++ mgmt/trunk/cumin/python/cumin/model.py 2009-08-05 13:50:07 UTC (rev 3543)
@@ -189,6 +189,8 @@
return self.enter(session, object).marshal()
def enter(self, session, object):
+ log.debug("Entering %s", self)
+
nsession = wooly.Session(self.app.form_page)
self.form.return_url.set(nsession, session.marshal())
@@ -196,6 +198,8 @@
self.do_enter(nsession, object)
+ log.info("Entered %s", self)
+
return nsession
def do_enter(self, session, object):
@@ -206,11 +210,15 @@
self.form.page.set_redirect_url(session, osession.marshal())
def exit(self, session, object):
+ log.debug("Exiting %s", self)
+
url = self.form.return_url.get(session)
osession = wooly.Session.unmarshal(self.app, url)
self.do_exit(osession, object)
+ log.info("Exited %s", self)
+
return osession
def do_exit(self, session, object):
@@ -230,9 +238,14 @@
raise Exception("Not implemented")
def start(self, session, object):
+ log.debug("Starting %s", self)
+
now = datetime.now()
- subject = session.user_session.subject
+ subject = None
+ if hasattr(session, "user_session"):
+ subject = session.user_session.subject
+
invoc = TaskInvocation(self, subject, object)
invoc.status = invoc.PENDING
invoc.start_time = now
@@ -240,15 +253,21 @@
self.app.model.task_invocations.append(invoc)
+ log.info("Started %s", self)
+
return invoc
def end(self, invoc):
+ log.debug("Ending %s", self)
+
now = datetime.now()
invoc.status = invoc.OK
invoc.end_time = now
invoc.last_change_time = now
+ log.info("Ended %s", self)
+
def exception(self, invoc, e):
now = datetime.now()
Show replies by date