I've never run threads before, so I'm not sure of what its implications
can be. I think I should dive into this subject further, once I get my
gears running in WebWare mode :)
  
You do not need threads.  Each webware servlet instance runs in its own thread so you do not have to worry about it.  That is why you can safely use self.xxxx to manager information about that page request. In Java you would have to be careful to bind any page variables to the Request object. 
If you need threads you just implement them as regular Python threads, just keep in mind that the user and session may no longer exists at the end of the run, and the AppServer may want to shutdown in the middle of your run as well.
For logging it is an easy matter to rewrite the log using SQL.  I use
the console log as a developer tool and the SQL log as a site analysis
tool.
    

When using your own logging engine, do you change the appserver program,
of hook it somewhere (configuration files?)
For non-debug logging I simply setup some instance properties that I am interested in and the at sleep I write them to a SQL table;

class SitePage(Page):
    ......

    def setUpLog(self,actionCode,actionDesc):
        self._actionCode = actionCode
        self._actionDesc = actionDesc

    def sleep(self,trans):
        if (self._user):
            username = self._user.name
        else:
            username = 'Anonymous'
        myLog.writeLog(username,self._actionCode,self._actionDesc)
        Page.sleep(self,trans)

and then in my main classes I have something like:

class news(SecurePage):
....
   
    def  prepareContent(self)
       category = self.request().value('category','None')
       ....
       self.setupLog('news','viewing news page, filtered by Category::%s' % category)
      

This type of log will not log an entry if there was an error though, for that you should use the standard logging module in the usual way.  Just put convience functions in SitePage so you do not have to think about it.

-Aaron


Reply via email to