From: Stephan D. <ste...@gm...> - 2003-03-06 10:23:38
|
On Thursday 06 March 2003 10:32, you wrote: > On Wed, 2003-03-05 at 12:17, Stephan Diehl wrote: > > Hi all, > > I'm developing with Webware for quite a while and I still think that > > working with applets is not as intuitive as it might be. This has in > > principle nothing to do with Webware but with Web development in general. > > Now, using Python, gives us a lot of tools that can be used for our > > advantage. > > Whoops, I read "applets" and then ignored the thread, thinking it was > another client-side Java thread, but I think you meant "servlet". Oops, sorry, yes, it should have read "servlet" :-) > > > class CountVisits(ExamplePage): > > > > def writeContent(self): > > self.count += 1 > > self.writeln(self.count) > > I would entirely support -- and proposed at one time -- that you should > be able to do > self.session.count += 1 > though I do wonder if it wouldn't be as pretty when you'd be forced to > do > self.session.count = getattr(self.session, 'count', 0) + 1 > because sessions are being created all the time, so you usually have to > expect that they may be empty. In my example, the initial value for that session variable would have been in the class attribute "_sessionData_". ------------------------------------------------------------ class CountVisits(ExamplePage): _sessionData_ = {'count':0} ------------------------------------------------------------ > You'd almost need something like an > __init__ for the session objects (an __init__ that was for your > particular application, of course, not Webware's Session.__init__). But > that __init__ would be application-wide, but individual servlets might > have specific expectations, and putting all those expectations into one > session initialization would be annoying. So maybe it would be useful > only if it was developed further. Yes, I totally agree. I haven't ment to present a "solution" but only a little thing to talk about. If I'm to really implement this, I'll make the session more fine grained than that (per page, per session, per action,...) > > I've also thought about it for requests, though it becomes awkward as > well when you don't want to depend on all the variables being present. > Now the idea top in my mind is expansion, like: > > def someAction(self, var1, var2_int, var3="something"): > ... > > So that var1 and var2 would be required variables, and var2 would be > turned into an int. I hate Zope's method of using an HTML variable name > of var2:int, and I'd rather see the HTML have var2, and the function > definition have the type declaration in it. This sounds neat. I'd even like to have some machinery in place to check the content of the request variables not only on type but for value (like you are doing in your FunFormKit) > > But that just works for request variables, the analog wouldn't work for > sessions. > > > Making the session the implicit storage for all servlet instance > variables doesn't seem like a good idea. I don't like implicit stuff > like that at all. The burden of typing "self.session" instead of just > "self" is not great enough to justify introducing that sort of magic > behavior. Yes and no. I'd like to be able to have more abstraction from the underlying HTTP/Page concept. I don't want to think in terms of pages, session, request but in terms of a "real" application. For example, if I were to develop a web mail frontend, I'd like to program it in a way as if it were a standalone client application. With this in mind, it wouldn't make a lot of sense to talk about a specific "session" as the application itself takes care of it's state. I know that this goal is very far off, but I just like to dream... > > Ian Stephan |