Laurence Rowe wrote:
[snip]
Why not just have:
class IDatabase(Interface):
"""A utility that specifies the database.
"""
def session_factory():
"""Create a new session
"""
def id():
"""Get unique id for this database configuration.
This should be unique per site (application).
"""
This looks quite a lot like my proposed new IDatabase, which in fact
also has a scopefunc() method, so that you can have a simple per-thread
scope if you don't care about per-application scopes.
class Database(grok.LocalUtility):
grok.implements(IDatabase)
def session_factory(self):
engine = create_engine(
'postgres:///experiment',
convert_unicode=True)
return create_session(
bind=engine,
autocommit=True,
autoflush=True,
extension=ZopeTransactionExtension())
def id(self):
# we use the application name as the unique id. Can we use
# something more clever and universally working?
return self.__parent__.__name__
Yes, that would be good. I'm just making sure it's wise to recreate an
engine for each thread/application.
Regards,
Martijn
_______________________________________________
Zope-Dev maillist - Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )