Re: [Webware-devel] Custom session store and session classes
Hi Ben, I'm going to implement your patch, but I'd like to cut down the number of additional config settings. The number of parameters is already scaring enough ;-) What do you think about: 1) Assuming that the class name is always the same as the module name (this is also backward compatible and reduces confusion). 2) If the setting contains no dot, then try Session%sStore % setting, if this fails or the name contains a dot, then use the name as is. This way we can get on only with the old 'SessionStore' setting in a backward compatible way, plus one additional setting for the session module (and class). Would this be ok for you? -- Chris Ben Parker wrote: Hi - It would be really nice to have the session store class and session classes fully configurable from the Application.config file. Currently Webware is limited to the included Memory/File/Dynamic setting which is translated into (Session%sStore % setting) and used to import the store. Then the session class is hard-coded as Session in the Application. What do you think of having config settings for importing custom session stores and session classes for use by the app? I built a custom store for one application that happens to use MySQL as the back-end, coupled with a custom Session object, and I have to jump through some hoops to get the app to use them. It could be as simple as four new config settings: SessionStoreModule SessionStoreClass SessionModule SessionClass The Application object could do the same process it does now to import SessionXxxStore. Something like this (rough, untested): CURRENT: # For session store: sessionStore = 'Session%sStore' % self.setting('SessionStore') exec 'from %s import %s' % (sessionStore, sessionStore) klass = locals()[sessionStore] assert isinstance(klass, ClassType) or issubclass(klass, Object) self._sessions = klass(self) NEW: # For session store: exec 'from %s import %s' % (self.setting('SessionStoreModule'), self.setting('SessionStoreClass')) klass = locals()[self.setting('SessionStoreClass')] assert isinstance(klass, ClassType) or issubclass(klass, Object) self._sessions = klass(self) # For session class: exec 'from %s import %s' % (self.setting('SessionModule'), self.setting('SessionClass')) klass = locals()[self.setting('SessionClass')] self._session = klass If there is interest in this, I can whip up a patch. I can include support for the current SessionStore param as well, rather than force a change to config files. Thanks - Ben - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Webware-devel mailing list Webware-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/webware-devel
Re: [Webware-devel] Custom session store and session classes
Yes that would work fine for our app. Agreed about too many config settings - I thought about having the Session / SessionStore set through some kind of runtime configuration. Allow each context to set its own session/store combo perhaps? but that is a larger effort, and I didn't need that full solution. :) Thanks for considering the patch, and thank you very much for your work on the Webware releases! Regards - Ben Christoph Zwerschke wrote on 4/5/07 8:50 AM: Hi Ben, I'm going to implement your patch, but I'd like to cut down the number of additional config settings. The number of parameters is already scaring enough ;-) What do you think about: 1) Assuming that the class name is always the same as the module name (this is also backward compatible and reduces confusion). 2) If the setting contains no dot, then try Session%sStore % setting, if this fails or the name contains a dot, then use the name as is. This way we can get on only with the old 'SessionStore' setting in a backward compatible way, plus one additional setting for the session module (and class). Would this be ok for you? -- Chris Ben Parker wrote: Hi - It would be really nice to have the session store class and session classes fully configurable from the Application.config file. Currently Webware is limited to the included Memory/File/Dynamic setting which is translated into (Session%sStore % setting) and used to import the store. Then the session class is hard-coded as Session in the Application. What do you think of having config settings for importing custom session stores and session classes for use by the app? I built a custom store for one application that happens to use MySQL as the back-end, coupled with a custom Session object, and I have to jump through some hoops to get the app to use them. It could be as simple as four new config settings: SessionStoreModule SessionStoreClass SessionModule SessionClass The Application object could do the same process it does now to import SessionXxxStore. Something like this (rough, untested): CURRENT: # For session store: sessionStore = 'Session%sStore' % self.setting('SessionStore') exec 'from %s import %s' % (sessionStore, sessionStore) klass = locals()[sessionStore] assert isinstance(klass, ClassType) or issubclass(klass, Object) self._sessions = klass(self) NEW: # For session store: exec 'from %s import %s' % (self.setting('SessionStoreModule'), self.setting('SessionStoreClass')) klass = locals()[self.setting('SessionStoreClass')] assert isinstance(klass, ClassType) or issubclass(klass, Object) self._sessions = klass(self) # For session class: exec 'from %s import %s' % (self.setting('SessionModule'), self.setting('SessionClass')) klass = locals()[self.setting('SessionClass')] self._session = klass If there is interest in this, I can whip up a patch. I can include support for the current SessionStore param as well, rather than force a change to config files. Thanks - Ben - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Webware-devel mailing list Webware-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/webware-devel - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Webware-devel mailing list Webware-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/webware-devel
Re: [Webware-devel] Custom session store and session classes
Ok, this is now in the trunk if you want to check it out. Ben Parker wrote: Agreed about too many config settings - I thought about having the Session / SessionStore set through some kind of runtime configuration. Allow each context to set its own session/store combo perhaps? but that is a larger effort, and I didn't need that full solution. :) - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Webware-devel mailing list Webware-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/webware-devel