[Zope] Problem with Z SQL Method associated with a class...

Frederic Quin frederic.quin@free.fr
Fri, 06 Oct 2000 18:37:46 +0200


Hi all,


I associated a Z SQL Method to a class. This class MUST have attributes
but I obtain a Zope error on them. Did anyone know why and what I can do
???


Thanks
Fred


HERE IS THE ERROR ----------------------------------------
Error

               Zope has encountered an error while publishing this
resource. See below for details. 

               Error Type: AttributeError
               Error Value: interests_founded



               Troubleshooting Suggestions

                    The URL may be incorrect. 
                    The parameters passed to this resource may be
incorrect. 
                    A resource that this resource relies on may be
encountering an error. 

               For more detailed information about the error, please
refer to the HTML source for this page. 

               If the error persists please contact the site maintainer.
Thank you for your patience. 


                                                   Version 2.0.1 -- ©
2000 Profile For You -- Internal use only.

Traceback (innermost last):
  File
/usr/local/Zope-2.1.6-linux2-x86/lib/python/ZPublisher/Publish.py, line
214, in publish_module
  File
/usr/local/Zope-2.1.6-linux2-x86/lib/python/ZPublisher/Publish.py, line
179, in publish
  File /usr/local/Zope-2.1.6-linux2-x86/lib/python/Zope/__init__.py,
line 202, in zpublisher_exception_hook
    (Object: ElementWithAttributes)
  File
/usr/local/Zope-2.1.6-linux2-x86/lib/python/ZPublisher/Publish.py, line
165, in publish
  File /usr/local/Zope-2.1.6-linux2-x86/lib/python/ZPublisher/mapply.py,
line 160, in mapply
    (Object: index_html)
  File
/usr/local/Zope-2.1.6-linux2-x86/lib/python/ZPublisher/Publish.py, line
102, in call_object
    (Object: index_html)
  File /usr/local/Zope-2.1.6-linux2-x86/lib/python/OFS/DTMLDocument.py,
line 166, in __call__
    (Object: index_html)
  File
/usr/local/Zope-2.1.6-linux2-x86/lib/python/DocumentTemplate/DT_String.py,
line 502, in __call__
    (Object: index_html)
  File /usr/local/Zope-2.1.6-linux2-x86/lib/python/OFS/DTMLMethod.py,
line 146, in __call__
    (Object: dmProfileCompare)
  File
/usr/local/Zope-2.1.6-linux2-x86/lib/python/DocumentTemplate/DT_String.py,
line 502, in __call__
    (Object: dmProfileCompare)
  File
/usr/local/Zope-2.1.6-linux2-x86/lib/python/DocumentTemplate/DT_In.py,
line 691, in renderwob
    (Object: sqlSiteProfileDetails( WEBSITEID=REQUEST.id,
PAGEID=REQUEST.pg ))
  File
/usr/local/Zope-2.1.6-linux2-x86/lib/python/DocumentTemplate/DT_Util.py,
line 335, in eval
    (Object: XMLToDict(REQUEST.pstor))
    (Info: REQUEST)
  File <string>, line 0, in ?
  File /Zope/Extensions/IntranetToolKit.py, line 132, in XMLToDict
    (Object: Profile4uXMLParser)
AttributeError: (see above)



HERE IS MY CLASS ----------------------------------------------------
import string
import sys
from Shared.DC.xml import *
from Shared.DC.xml.pyexpat import *


class Profile4uXMLParser:

  # Necessary method to make the pyexpat module works

  def start_element(self, name, attrs):
          self.current_name = name

                                # Simple tag for which we just want to
store the attributes or the value situated just after the tag

          if ((name != 'interests') and (self.interests_founded == 0)):

             for i in range(len(attrs)):
                if ((i % 2) == 0):
                  self.datas[attrs[i]] = attrs[i+1]

                                # If we have a value just after the tag,
it will be associate with the name of the tag after

             if (name != 'profile'):
                self.datas[name] = ''

                                # We find the tag interests so...

          elif (self.interests_founded == 0):
               self.interests_founded = 1

                                # Tag founded in the tag interests

          else:
            tmp = {}
            tmp['level'] = string.replace(name,'l','')

            for i in range(len(attrs)):
                if ((i % 2) == 0):
                   tmp[attrs[i]] = attrs[i+1]

            self.interests.append(tmp)



  # Necessary method to make the pyexpat module works

  def end_element(self, name):
                                # End of interests : we can find others
simple tags

          if (name == 'interests'):
             self.interests_founded = 0



  # Necessary method to make the pyexpat module works

  def char_data(self, data):
                                # Association of the value founded just
after the tag with the name of the tag

          if ((self.current_name != 'interest') and
(self.interests_founded == 0)):

                                # If the data need to be decoded...

             if (string.find(data,':') >= 0):
                tmp2 = {}
                tmp = string.split(data,':')

                for i in range(len(tmp)):
                   if ((i % 3) == 0):
                      tmp2[tmp[i]] = [tmp[i+1],tmp[i+2]]

                self.datas[self.current_name] = tmp2

             else:
                self.datas[self.current_name] = data




  def XMLToDict(self, dict):
      self.interests_founded = 0                 # To know when we have
found the interests
      self.datas = {}                            # To store all general
informations
      self.current_name = ''                     # To associate the
information located just after a tag to the name of this tag (see
char_data method)
      self.interests = []                        # To store temporaly
the interests

      p = pyexpat.ParserCreate()

      p.StartElementHandler = self.start_element
      p.EndElementHandler   = self.end_element
      p.CharacterDataHandler= self.char_data

      if (self.INTEREST != 'false'):
         p.Parse(self.INTEREST)
         dict[self.datas['type']] =  [self.datas,self.interests]

      return dict