[Zope-dev] ZSQLMethod/Z Database Connection namespace

2002-10-29 Thread Jeff Coleman
Hi,
I have a product that stores customer information in mysql using
ZSQLMethods. 
I would like each customer to have a different mysql database (same
structure), but all use the same ZSQLMethods for access.
So, I tried the following:
/ - root contains ZSQLMethods and default DB Connector (seems to be
required for editing the methods)
/CustomerA - contains DB Connector with same name as in root, but uses
different mysql database
/CustomerB - contains DB Connector with same name as in root, but uses
different mysql database

And assumed that /CustomerA/showdata would use the DB Connector in the
'CustomerA' directory, but no matter what it uses the DB Connector in
the root directory.  It seems that the ZSQLMethods namespace is put on
top and any other DB Connectors are ignored.
Is this intentional or a bug?

I can patch Shared.DC.ZRDB.DA with the following:

try: nsCid = getattr(aq_parent(self), self.connection_id)
except: ns = self
else: ns = aq_parent(self)

#try: dbc=getattr(self, self.connection_id) --- old code
try: dbc=getattr(ns, self.connection_id)

Is this the only way to solve the problem? 
I hate to add a patch to get what would seem to me to be the correct
functionality.

Thanks,
Jeff

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] ZSQLMethod/Z Database Connection namespace

2002-10-29 Thread Dieter Maurer
Jeff Coleman writes:
  I have a product that stores customer information in mysql using
  ZSQLMethods. 
  I would like each customer to have a different mysql database (same
  structure), but all use the same ZSQLMethods for access.
  So, I tried the following:
  / - root contains ZSQLMethods and default DB Connector (seems to be
  required for editing the methods)
  /CustomerA - contains DB Connector with same name as in root, but uses
  different mysql database
  /CustomerB - contains DB Connector with same name as in root, but uses
  different mysql database
  
  And assumed that /CustomerA/showdata would use the DB Connector in the
  'CustomerA' directory, but no matter what it uses the DB Connector in
  the root directory.  It seems that the ZSQLMethods namespace is put on
  top and any other DB Connectors are ignored.
  Is this intentional or a bug?
It is intentional and called Containment before Context.
Read the acquisition section in

  http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html

to learn more about it.

It was implemented this way mainly because the security framework
should be based on acquisition too, and there, you do not want
that the context can override the security policies defined higher
up in the hierarchy.


Dieter

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )