[mod_python] Minidom parse error

Dan R. Olsen III python at dan-olsen.net
Thu Dec 23 11:08:27 EST 2004


As I have been looking at it, I actually get two different error 
messages to the code listed below. The first error is at the bottom of 
this message and the other error is:

----- BEGIN OUTPUT -----

Mod_python error: "PythonHandler rose"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 193, in Dispatch
    result = object(req)

  File "/web/htdocs/dev/rose.py", line 7, in handler
    filedoc = xml.dom.minidom.parse(xmlfile)

  File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line 1907, in parse
    from xml.dom import expatbuilder

  File "/usr/lib/python2.3/site-packages/_xmlplus/dom/expatbuilder.py", line 32, in ?
    from xml.parsers import expat

  File "/usr/lib/python2.3/site-packages/_xmlplus/parsers/expat.py", line 4, in ?
    from pyexpat import *

ImportError: /usr/lib/python2.3/site-packages/_xmlplus/parsers/pyexpat.so: undefined symbol: PyUnicodeUCS4_Decode

----- END OUTPUT -----

I haven't found anything when I Google for these errors. Can anyone help?



Dan R. Olsen III wrote:

> I am trying to parse a file that I am getting from a url. However, I 
> keep getting an error saying that a module does not have an attribute 
> parse. Here is the code followed by the error:
>
> ----- BEGIN CODE -----
>
> import xml.dom.minidom
> #from xml.dom import minidom
> from mod_python import apache
> from dbxml import *
> import urllib
>
>
> ### GET ALL THE URLS FROM THE OPML FILE
> #######################################
> def get_urls(req, url):
>    #req.write(url + "\n")
>    xmlfile = 
> urllib.urlopen('http://www.windley.com/gems/mySubscriptions.opml')
>    #req.write(xmlfile + "Great!!")
>    filedoc = xml.dom.minidom.parse(xmlfile)
>    req.write("HOW ABOUT HERE\n")
>    feeds = []
>    text = filedoc.getElementsByTagName("outline")
>    for nodes in text:
>        for (name, value) in nodes.attributes.items():
>            if name == 'xmlUrl':
>                feeds.append(value)
>    return feeds
>
> ### SPLIT THE ARGUMENTS PASSED TO THE URL
> #########################################
> def split_args(args):
>    rose_args = {}
>    if args == None:
>        return rose_args
>
>    arglist = args.split('&')
>
>    for arg in arglist:
>        tmp = arg.split('=')
>        if len(tmp) == 1:
>            rose_args[tmp[0]] = None
>        else:
>            rose_args[tmp[0].upper()] = tmp[1]
>    return rose_args
>
> ### SEND ERROR IF SOMETHING GOES WRONG
> ######################################
> def send_html_error(req, s, status):
>    req.content_type = 'text/html'
>    req.send_http_header()
>    req.write('<p>' + s + '</p>')
>    raise apache.SERVER_RETURN, status
>
> ### MAIN HANDLER METHOD WHERE ARE THE MAIN CALLS ARE MADE
> #########################################################
> def handler(req):
>    req.send_http_header()
>
>    request = req.args
>    rose_args = split_args(req.args)
>    if len(rose_args) == 0:
>        send_html_error(req, 'No parameters found', 
> apache.HTTP_BAD_REQUEST)
>    if len(rose_args) != 2:
>        send_html_error(req, '<strong><font color=\"RED\">You must have 
> two parameters, one for \nyour OPML file and one for the 
> FLAVOR</font></strong>', apache.HTTP_PRECONDITION_FAILED)
>
>    url = rose_args.get('URL', None)
>    flavor = rose_args.get('FLAVOR', None)
>    if url == None:
>        send_html_error(req, '<strong><font color=\"RED\">No URL 
> parameter found</font></strong>', apache.HTTP_PRECONDITION_FAILED)
>    else:
>        req.write("OPML: " + url + "\n")
>
>    if flavor == None:
>        send_html_error(req, '<strong><font color=\"RED\">No FLAVOR 
> parameter found</font></strong>', apache.HTTP_PRECONDITION_FAILED)
>    else:
>        flavor = flavor.upper()
>        if(flavor != 'RSS' and flavor != 'ATOM'):
>            req.write("FLAVOR: " + flavor + "\n")
>            send_html_error(req, '<strong><font color=\"RED\">The 
> FLAVOR you entered is not a valid flavor</font></strong>', 
> apache.HTTP_PRECONDITION_FAILED)
>        else:
>            req.write("FLAVOR: " + flavor + "\n")
>
>    rose_urls = get_urls(req, url)      req.write(rose_urls[0])
>    mgr = XmlManager()
>    container = 
> mgr.openContainer("/web/htdocs/dev/danolsencreatedme.dbxml")
>
>    return apache.OK
>
> ----- END CODE -----
>
> ----- BEGIN OUTPUT ------
>
> OPML: http://www.windley.com/gems/mySubscriptions.opml
> FLAVOR: RSS
>
> Mod_python error: "PythonHandler rose"
>
> Traceback (most recent call last):
>
>  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 
> 193, in Dispatch
>    result = object(req)
>
>  File "/web/htdocs/dev/rose.py", line 78, in handler
>    rose_urls = get_urls(req, url)
>
>  File "/web/htdocs/dev/rose.py", line 14, in get_urls
>    filedoc = xml.dom.minidom.parse(xmlfile)
>
>  File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line 
> 1908, in parse
>    return expatbuilder.parse(file)
>
> AttributeError: 'module' object has no attribute 'parse'
>
> ----- END OUTPUT -----
>
> If anyone can clue me in on why this is happening that would be great!
>
> Dan Olsen
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20041223/28dc98e4/attachment-0001.html


More information about the Mod_python mailing list