[DB-SIG] Inheriting from a DBAPI 2.0 Cursor Object

Peter L. Buschman plblists at iotk.com
Fri Sep 26 06:38:30 EDT 2003


That's even better since that can still allow a pass-through to extended 
methods that are present in some of
the driver's out there ( in the case where the dal is used just as an 
intelligent driver loader. )

--PLB

At 06:55 PM 9/25/2003 -0700, Chris Cogdon wrote:

>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