Hi there. Possibly a rather stupid question, but I currently have some issues when using multiple inheritance and subclassed SQLObjects.
As an overview, the idea is to override certain aspects of SQLObjects to intercept various calls for event logging. Additionally, event-logged classes may or may not also require additional parameters which are defined in another class and then implemented using multiple inheritance. We're talking about a fairly large number of objects, so I don't feel like writing individual definitions for each class I want to log for, nor do I want to add individual properties for every class which requires them. As an idea, I'll assume the following: Class A - Event logging SQLObject class Class B - Additional method / properties Object class. Class C - A class requiring event logging and additional properties. That said, an example: #------------------------------------- import logging from sqlobject import * from sqlobject.inheritance import InheritableSQLObject log = logging.getLogger('testpython') class A(InheritableSQLObject): def _init(self, *args, **kw): log.debug("A - _init") InheritableSQLObject._init(self, *args, **kw) class B(Object): def _init(self, *args, **kw): self.additonalproperty = "bogusstring" + self.id class C(A, B): bogusfield = IntCol() def _init(self, *args, **kw): log.debug("C - _init") A._init(self, *args, **kw) B._init(self, *args, **kw) #------------------------------------- Now, a couple of reasons I've used the following: A._init has to be called before C._init, as self.id does not exist in B before A._init has been executed. But, if we execute the following, we see that although C._init is called once, A._init executes twice. #------------------------------------- c = C.get(1) 2007-03-14 11:45:34,513 testpython DEBUG C - _init 2007-03-14 11:45:34,513 testpython DEBUG A - _init 2007-03-14 11:45:34,674 testpython DEBUG A - _init #------------------------------------- Further playing around and overriding the __init__ methods of the classes A, B and C we have the following: #------------------------------------- import logging from sqlobject import * from sqlobject.inheritance import InheritableSQLObject log = logging.getLogger('testpython') class A(InheritableSQLObject): def __init__(self, *args, **kw): log.debug("A - __init__") InheritableSQLObject.__init__(self, *args, **kw) def _init(self, *args, **kw): log.debug("A - _init") InheritableSQLObject._init(self, *args, **kw) class B(Object): def _init(self, *args, **kw): self.additonalproperty = "bogusstring" + self.id class C(A, B): bogusfield = IntCol() def __init__(self, *args, **kw): log.debug("C - __init__") A.__init__(self, *args, **kw) def _init(self, *args, **kw): log.debug("C - _init") A._init(self, *args, **kw) B._init(self, *args, **kw) #------------------------------------- 2007-03-14 11:45:34,513 testpython DEBUG C - __init__ 2007-03-14 11:45:34,513 testpython DEBUG A - __init__ 2007-03-14 11:45:34,513 testpython DEBUG C - _init 2007-03-14 11:45:34,513 testpython DEBUG A - _init 2007-03-14 11:45:34,674 testpython DEBUG A - __init__ 2007-03-14 11:45:34,674 testpython DEBUG A - _init Naturally, this makes the use of subclassing SQLObject slightly unsatisfactory for event logging for my purposes, as we're talking about numerous log events for every single operation. Is there something I am missing here ? Or have I got some misconception about how to implement this ? Any assistance / advice appreciated. Regards, Ian ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss