[Dev] SSLDAV class, code design question

Heikki Toivonen heikki at osafoundation.org
Fri Oct 29 12:10:39 PDT 2004


Currently the DAV class inherits from httplib.HTTPConnection. There is 
also M2Crypto.https.HTTPSConnection that inherits from 
httplib.HTTPConnection. In other words:

httplib.HTTPConnection
   __init__()

DAV(httplib.HTTPConnection)

M2Crypto.httplibs.HTTPSConnection
   __init__()
     httplib.HTTPConnection.__init__()

Now, clearly it would be possible to create SSLDAV class that inherited 
from M2Crypto.https.HTTPSConnection and duplicated all the code from DAV.

But what is the best way to achieve this without code duplication? At 
the moment I am thinking that I should make the DAV class not inherit 
from anything, but make it a mixin class. Then, depending on whether or 
not we need SSL or non-SSL DAV, we instantiate 
M2Crypto.httplibs.HTTPSConnection or httplib.HTTPConnection and mix in 
the DAV class (using application.Application.mixinAClass or something 
like it.

Other thoughts that have occurred involve diamond inheritance and 
calling the wrong __init__ or needing to call __init__ more than once 
which may not be safe.

-- 
   Heikki Toivonen


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : http://lists.osafoundation.org/pipermail/dev/attachments/20041029/0ee864e0/signature.bin


More information about the Dev mailing list