ver2 - (v1 may have gotten lost)
> Change that last line to:
>
> con = dabo.db.dConnection(ci)
> self.setConnection(con)
Ok, that worked. thanks. One step closer, but still not out of the woods.
My getDBs method is MySql specific. I think it should be in the Data tier, not
middle tier. (could be wrong, but it sure smells like data tier.)
So my thought is: subclass dbMySQL and add a method.
But I don't see how to use my subclass. I found this line
cursorClass = self._getCursorClass(self.dCursorMixinClass,
self.dbapiCursorClass)
And thought about setting self.dbapiCursorClass, but then I found this:
def setConnection(self, conn):
"""Normally connections are established before bizobj creation,
but
for those cases where connections are created later, use this
method to
establish the connection used by the bizobj.
"""
self._cursorFactory = conn
if conn:
# Base cursor class : the cursor class from the db api
self.dbapiCursorClass =
self._cursorFactory.getDictCursorClass()
So there is no way self.dbapiCursorClass is going to help.
Also, I just noticed that I am sub-classing the BO module, not the BO class,
right? so now I am not even sure how to subclass the dabo MySQL class. must
be another case of name space gork.
import dabo
import dabo.db.dbMySQL
class uLoopDO(dabo.db.dbMySQL.MySQL):
def getDBs(self,user):
""" get the list of DBs the user has access to """
self.execute("""select distinct table_schema
from information_schema.SCHEMA_PRIVILEGES
where GRANTEE like %(user)s
""", {'user':'%'+user+'%'} )
return rows
class uLoopBO(dabo.biz.dBizobj):
def findDBs(self):
ci = dabo.db.dConnectInfo(DbType='mysql',
Host=self.host,
User=self.user,
PlainTextPassword=self.pw )
con = dabo.db.dConnection(ci)
self.setConnection(con)
self._CurrentCursor.getDBs(self.user)
def test(self):
self.host = 'sahara'
self.user = 'testUserA'
self.pw = 'pw'
self.findDBs()
if __name__ == "__main__":
uLoopBO1=uLoopBO()
uLoopBO1.test()
Traceback (most recent call last):
File "/home/carl/dev/apps/foo/test2.py", line 40, in <module>
uLoopBO1.test()
File "/home/carl/dev/apps/foo/test2.py", line 34, in test
self.findDBs()
File "/home/carl/dev/apps/foo/test2.py", line 27, in findDBs
self._CurrentCursor.getDBs(self.user)
AttributeError: 'cursorMix' object has no attribute 'getDBs'
Script terminated.
Carl K
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]