Michael Bayer wrote:
how about this: import sqlalchemy.ext.sessioncontext as sessioncontextcontext = sessioncontext.ThreadLocalSessionContext() # create_session is the default factory class Foo(object):__metaclass__ = context.metaclass class Bar(object): __metaclass__ = context.metaclass
Ahh yes, that's much better than my create_metaclass function. I'm not sure why I didn't think of making it a method of SessionContext as it should be (probably because I wanted to keep that as simple as possible).
also, with create_baseclass, should we call it more of a mixin ? that way it doesnt get in the way of an inheritance hierarchy (even though it would usually be at the base...but then maybe someone wants different contexts in one hierarchy !):context = sessioncontext.ThreadLocalSessionContext()class Bar(Foo, context.mixin):# etc..
I don't really have a problem with this as long as it can be used directly as the base class. What would actually change? just the name? why bother? I still haven't made up my mind about super() yet...previously I had thought it was the way to go and started using everywhere. Just tonight I went back and re-read James Knight's infamous article about the pitfalls inherent in using super(). I almost changed my mind again (against using super), but then I reverted back to my old rule: never use multiple inheritance if it can be avoided (which I think makes it irrelevant whether one uses super() or Class.method(self, ...); please correct me if I'm wrong). So far this has not let me down. In fact I've never even found a case where I couldn't avoid it. Taking all that into consideration, I would not advise the use of multiple inheritance, and therefore would be against advocating the use of a mixin. But I have no problem with providing a class that _could be used_ as a mixin if th e user knows what s/he's doing and is willing to take the responsibility for the consequences. In this case that user should be able to recognize that the class could be used as a mixin rather than having the name suggest that it should be used that way. My vote is for this: class X(context.baseclass): ...
im just going for something as sparse as possible here...things catch on better when theyre like that !
Yes, I agree. Keep it simple.
also i have shuffled around the packages as I described, session stuff is in sqlalchemy.orm.session, the "objectstore" name is only in the threadlocal mod at the moment.
+1 that's much better than sqlalchemy.mapping... ------------------------------------------------------- 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

