> So would it work like this: > > callable = MyClass.__sessioncontext__ > session = callable() > > or like this: > > callable = MyClass.__sessioncontext__() > session = callable() > > I'm not really liking the second one because it requires this to get a > session directly from the object: > > session = MyClass.__sessioncontext__()() > > which is ugly and confusing IMHO.
I agree. But in that case it's misnamed, IMO. It should be __session__, or something like __instancesession__ and __classsession__, if using the concepts I suggested in the other mail. I'd expect to get a context from a method named __sessioncontext__, and while your SessionContext implementation could be used, I wouldn't like to be enforced to use it when I can return the session myself using the logic I want. > SessionContext's "current" property is more powerful than Hibernates > equivalent currentSession() method because it allows get, set, and del. > Also, if you really want to implement a __call__ method on SessionContext > then we should just make it extend ScopedRegistry rather than wrapping it > since ScopedRegistry already implements __call__ (less method calls => > faster). I think an attribute is the most natural (it's probably what > Hibernate would use if Java had properties like Python). Again, a callable that returns a session is simple and flexible. That's what the API should require. Then, SessionContext, ScopedRegistry, or whatever one wants can be used to support that callable. > I still hold to my suggestion to name it to __contextsession__(). It > should be a callable that returns a Session instance. Then if you want > to pass around a callable it can be done like this: > > session_getter = MyClass.__contextsession__ __contextsession__, __session__, ... -- Gustavo Niemeyer http://niemeyer.net ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Sqlalchemy-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

