[PEAK] peak DMs and model element component hierarchy

Phillip J. Eby pje at telecommunity.com
Sat Jul 17 00:52:33 EDT 2004


At 11:42 PM 7/16/04 -0500, Doug Quale wrote:

>So, I'm not sure what to do with the connections.  I guess they are
>part of a composite id for the model objects because the same database
>names can be found on different servers, same table names in different
>databases on the same server, etc.  The original code takes the
>unclean approach of throwing everything into an Active Record.  Using
>a more proper domain model and separate DMs is cleaner, but I don't
>know how to manage the many connections that the DMs need.

As you said, they are part of a composite ID.  Let the DM keep a cache of 
database URLs to connection objects, something like:


     cache = binding.Make(dict)

     def getConnForURL(self,url):
         try:
             return self.cache[url]
         except KeyError:
             conn = self.lookupComponent(url,adaptTo=storage.ISQLConnection)
             self.cache[url] = conn
             return conn

And then use the connection URL as part of the OID of the relevant objects.




More information about the PEAK mailing list