[Zope] XML document error

zope zope@stylusinc.net
Sun, 12 Jan 2003 21:39:37 +0530


Hi all
I was trying to create an XML Document as  Specified in the Zope Book .
## Script (Python) "query"
        ##
        import string
        # get the XML Document, must use getattr since
        # the id is not a legal Python identifier
        doc=getattr(context, 'addressbook.xml')

        # get the document element
        book=doc.documentElement

        # count items, assuming all children are items
        print "Number of items", len(book.childNodes)

        # get names of items
        names=[]
        for item in book.childNodes:
            # assumes first child is name
            name=item.firstChild
            # assumes name has one child which is a text node
            names.append(name.firstChild.nodeValue)
        print "Names ", string.join(names, ",")
        return printed

The error thrown is :-
Error Type: AttributeError
Error Value: documentElement
Traceback (innermost last):
  File /Users/zope/Zope-2.5.1/lib/python/ZPublisher/Publish.py, line 150, in
publish_module
  File /Users/zope/Zope-2.5.1/Products/Localizer/__init__.py, line 65, in
new_publish
  File /Users/zope/Zope-2.5.1/lib/python/ZPublisher/Publish.py, line 114, in
publish
  File /Users/zope/Zope-2.5.1/lib/python/Zope/__init__.py, line 159, in
zpublisher_exception_hook
    (Object: john)
  File /Users/zope/Zope-2.5.1/lib/python/ZPublisher/Publish.py, line 98, in
publish
  File /Users/zope/Zope-2.5.1/lib/python/ZPublisher/mapply.py, line 88, in
mapply
    (Object: pytho_xmltest)
  File /Users/zope/Zope-2.5.1/lib/python/ZPublisher/Publish.py, line 39, in
call_object
    (Object: pytho_xmltest)
  File /Users/zope/Zope-2.5.1/lib/python/Shared/DC/Scripts/Bindings.py, line
252, in __call__
    (Object: pytho_xmltest)
  File /Users/zope/Zope-2.5.1/lib/python/Shared/DC/Scripts/Bindings.py, line
283, in _bindAndExec
    (Object: pytho_xmltest)
  File
/Users/zope/Zope-2.5.1/lib/python/Products/PythonScripts/PythonScript.py,
line 302, in _exec
    (Object: pytho_xmltest)
    (Info: ({'script': <PythonScript instance at 8da7d48>, 'context':
<Folder instance at 8ddfa58>, 'container': <Folder instance at 8ddfa58>,
'traverse_subpath': []}, (), {}, None))
  File Script (Python), line 8, in pytho_xmltest
  File /Users/zope/Zope-2.5.1/lib/python/AccessControl/ZopeGuards.py, line
47, in guarded_getattr
    (Object: addressbook.xml)
AttributeError: (see above)

Could you please tell me where I have gone wrong.Is there some eror in the
way I am handling the getattr()  I have used.
Also could you please tell me where I could find details of where the
different functions or methods available in a defined python object and how
it can be used in Zope.Thanks for all help in advance.

Thanks and Best Regards
John Kunchandy


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.435 / Virus Database: 244 - Release Date: 12/30/2002