[DB-SIG] Inheriting from a DBAPI 2.0 Cursor Object
Chris Cogdon
chris at cogdon.org
Thu Sep 25 21:55:12 EDT 2003
On Thursday, Sep 25, 2003, at 18:19 US/Pacific, Peter L. Buschman wrote:
>
> Chis:
>
> Thanks so much. I had been so focused on finding an inheritance
> solution ( difficult since the Connection and Cursor objects are not
> exposed
> directly in DBAPI ) that I completely missed simply wrapping the
> relevant objects. DBAPI is not that complex, so wrapping the methods
> is not
> that much extra code.
You're welcome.
As a general solution, you can also include a 'auto wrapper' that will
pass through calls to the wrapped object if they're not defined at the
current level.
Just put:
def __getattr__ ( self, name ):
return getattr ( self.db, name )
... into the class, and then you won't have to write 'trivial' wrappers
for all the methods that simply pass the call to the wrapped object.
--
("`-/")_.-'"``-._ Chris Cogdon <chris at cogdon.org>
. . `; -._ )-;-,_`)
(v_,)' _ )`-.\ ``-'
_.- _..-_/ / ((.'
((,.-' ((,/ fL
More information about the DB-SIG
mailing list