[Zope-DB] Problems with new attributes on Pluggable Brains classes

Liam Herron liam_herron@hotmail.com
Sat, 24 Nov 2001 16:06:37 -0500


I have two problems with pluggable brains:
   1) I cannot have the class I use for the Pluggable Brain be subclassed
      from another class.  When I attempt this, I get AttributeError on
      the attributes which I am trying to subclass from:

      class A:
         def __init__(self):
            self.testattr1 = "HELLO"

      class B(A):
         def __init__(self):
            A.__init__(self)

      class B is what I want the Z SQL Method to plug into.  I just want
      to have other attributes as well.


   2)  To work around the problem in 1, I tried to flatten my class 
hierarchy
       and I still get the AttributeError:

       class B:
          def  __init__(self):
             self.testattr1 = "HELLO"

       Here is the actual traceback:

Error Type: AttributeError
Error Value: testattr1


Traceback (innermost last):
  File 
/home/herronli/Zope-2.4.3-linux2-x86/lib/python/ZPublisher/Publish.py, line 
223, in publish_module
  File 
/home/herronli/Zope-2.4.3-linux2-x86/lib/python/ZPublisher/Publish.py, line 
187, in publish
  File /home/herronli/Zope-2.4.3-linux2-x86/lib/python/Zope/__init__.py, 
line 226, in zpublisher_exception_hook
    (Object: sqlOptionQueryByUnderlying)
  File 
/home/herronli/Zope-2.4.3-linux2-x86/lib/python/ZPublisher/Publish.py, line 
171, in publish
  File /home/herronli/Zope-2.4.3-linux2-x86/lib/python/ZPublisher/mapply.py, 
line 160, in mapply
    (Object: manage_test)
  File 
/home/herronli/Zope-2.4.3-linux2-x86/lib/python/ZPublisher/Publish.py, line 
112, in call_object
    (Object: manage_test)
  File /home/herronli/Zope-2.4.3-linux2-x86/lib/python/Shared/DC/ZRDB/DA.py, 
line 397, in manage_test
    (Object: sqlOptionQueryByUnderlying)
  File 
/home/herronli/Zope-2.4.3-linux2-x86/lib/python/DocumentTemplate/DT_String.py, 
line 546, in __call__
    (Object: <string>)
  File 
/home/herronli/Zope-2.4.3-linux2-x86/lib/python/DocumentTemplate/DT_In.py, 
line 653, in renderwb
    (Object: sqlOptionQueryByUnderlying)
  File 
/usr/local/Zope-2.4.3-linux2-x86/lib/python/Shared/DC/ZRDB/Results.py, line 
188, in __getitem__
  File 
/usr/local/Zope-2.4.3-linux2-x86/lib/python/Shared/DC/ZRDB/Results.py, line 
164, in __init__
  File /usr/local/Zope-2.4.3-linux2-x86/Extensions/LEO.py, line 11, in 
__init__
AttributeError: (see above)


Am I not allowed to add another attribute to this Record object?  How did 
they
restrict this?  I looked at the code for pluggable brains and I cannot seem
to see where it restricts me from adding new attributes

PLEASE HELP!


Liam Herron


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp