Python has scoping rules built it -Definatelly, scoping rules are very important. I was thinking along the line of a "task scope": There are session variables that are global (within an application) like for example "user" and some that are only used to communicate some values from "awake" to any other classmethod.Another, more webwarish approach might be to setup your setters and getters in the session class itself, and then call self.session.count = 5Well, that's probably my point. I don't want to be webwarish :-) I want to develop a webapplication as if it were a standalone application.
servlet instance = self.count
class myServlet:
def writeHTML(self):
self.count +=1
all servlet instances (Java Static - Python Module Level) -
count = 0
class myServlet:
def writeHTML(self):
count +=1
application level - use Modules
import UserFunctions
class myServlet:
def writeHTML(self):
UserFunctions.count +=1
I personally use instance variables alot - they make it easy to hold state across different functions. In light of the Twisted discussion I think it would be better to always bind a 'request' level varaiable to the request object and pass that around.
I do like your addition to make the session value automatically persist - rather then having to 'set' it all the time though.
-Aaron
