I agree with the issue about confusing the beginner with a redirection like that. Though, if you really want to, you could use a proxy and not muck with changing the getattr and setattr methods of the servlet, or the session:

#------ begin Test.py

from WebKit.Page import Page

class Test(Page):

        def awake (self, transaction):
                Page.awake(self, transaction)
                self.session = SessionProxy(self.session())
                self.session.x = range(20)
                                
        def writeContent (self):
                self.write(str(self.session.x))

class SessionProxy:
        def __init__ (self, session):
                self.__dict__['session'] = session
        def __getattr__ (self, attr):
                return self.__dict__['session'].value(attr)
        def __setattr__ (self, attr, value):
                self.__dict__['session'].setValue(attr, value)

#--- end Test.py

On Wednesday, March 5, 2003, at 01:05 PM, Jim Bucher wrote:

I think its better to keep session data and servlet data seperate. How many session variables do you really need compared to servlet variables?
Also by hiding the session data, uninitiated programmers will end up stomping session variables. If I have a CountUsers servlet and it also has a count variable, it will overwrite the variable used in CountVisits.


Stephan Diehl wrote:

Instead of using session data (or request data for that matter) in the usual way, I'd rather have some magic involved to let me use this data as normal servlet attributes.



-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. > www.etnus.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss






-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to