quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Graham Dumpleton" <grah...@dscpl.com.au>
Subject Re: Issues with "Session use with classes" wiki example.
Date Tue, 05 Dec 2006 02:54:49 GMT
Graham Dumpleton wrote ..
> Next option is to use a wrapper class and you wrap every function that
> wants to
> be able to use sessions:
> 
>   class SessionEnabled:
>     def __init__(self, target):
>       self.__target = target
>     def __call__(self):
>       return util.apply_fs_data(self.__target, req.form)
> 
>   def _function(req, a, b):
>     return a,b
> 
>   function = SessionEnabled(_function)

Whoops forgot to create the session.

   class SessionEnabled:
     def __init__(self, target):
       self.__target = target
     def __call__(self):
       if not hasattr(req, 'session'):
         req.session = Session.Session(req)
       return util.apply_fs_data(self.__target, req.form)

Graham

Mime
View raw message