Modify

Opened 5 years ago

Closed 5 years ago

Last modified 20 months ago

#6392 closed defect (fixed)

AttributeError: type object 'lxml.etree.XSLT' has no attribute 'strparam'

Reported by: tomw@… Owned by: abompard
Priority: normal Component: OdtExportPlugin
Severity: normal Keywords: lxml
Cc: Trac Release: 0.11

Description

After installing the odtexport plugin I got the following error message:

Trac detected an internal error:

AttributeError: type object 'lxml.etree.XSLT' has no attribute 'strparam'

thanks,

Thomas

System Information:

User Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.6) Gecko/20091215 Ubuntu/9.10 (karmic) Firefox/3.5.6

Trac: 0.11.6

Python: 2.5.2 (r252:60911, Jan 4 2009, 18:00:02) [GCC 4.3.2]

setuptools: 0.6c8

SQLite: 3.5.9

pysqlite: 2.4.1

Genshi: 0.5.1

mod_python: 3.3.1

Pygments: 0.10

GIT: 1.5.6.5

jQuery: 1.2.6

Attachments (0)

Change History (17)

comment:1 Changed 5 years ago by abompard

  • Resolution set to fixed
  • Status changed from new to closed

Thanks for the report. This happens with versions of lxml < 2.2. I've adapted the code in r7339 to fix it, please update.

comment:2 Changed 5 years ago by tomw@…

  • Resolution fixed deleted
  • Status changed from closed to reopened

Updated to the new release, restarted server. However, the bug remains. Added the output, perhaps that helps.

br, Thomas

Most recent call last:

  • File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py", line 450, in _dispatch_request Code fragment:
    1. try:
    2. if not env and env_error:
    3. raise HTTPInternalError(env_error)
    4. try:
    5. dispatcher = RequestDispatcher(env)
    6. dispatcher.dispatch(req)
    7. except RequestDone:
    8. pass
    9. resp = req._response or []
    10. except HTTPException, e:
    Local variables: Name Value after [u' except RequestDone:', u' pass', u' resp = ... before [u' try:', u' if not env and env_error:', u' raise ... dispatcher <trac.web.main.RequestDispatcher object at 0xa2607ac> e AttributeError("type object 'lxml.etree.XSLT' has no attribute ... env <trac.env.Environment object at 0x9ee024c> env_error None exc_info (<type 'exceptions.AttributeError'>, AttributeError("type object ... filename '/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py' frames [{'function': '_dispatch_request', 'lines_before': [u' try:', u' ... has_admin True line u' dispatcher.dispatch(req)' lineno 449 message u"AttributeError: type object 'lxml.etree.XSLT' has no attribute ... req <Request "GET u'/wiki/WikiStart'"> resp [] tb <traceback object at 0xa24ac84> tb_hide None traceback u'Traceback (most recent call last):\n File ...
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py", line 206, in dispatch Code fragment:
    1. req.args.get('FORM_TOKEN') != req.form_token:
    2. raise HTTPBadRequest('Missing or invalid form token. '
    3. 'Do you have cookies enabled?')
    4. # Process the request and render the template
    5. resp = chosen_handler.process_request(req)
    6. if resp:
    7. if len(resp) == 2: # Clearsilver
    8. chrome.populate_hdf(req)
    9. template, content_type = \
    10. self._post_process_request(req, *resp)
    Local variables: Name Value chosen_handler <trac.wiki.web_ui.WikiModule object at 0xa26034c> chrome <trac.web.chrome.Chrome object at 0xa26074c> err (<type 'exceptions.AttributeError'>, AttributeError("type object ... handler <trac.wiki.web_ui.WikiModule object at 0xa26034c> req <Request "GET u'/wiki/WikiStart'"> self <trac.web.main.RequestDispatcher object at 0xa2607ac>
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/wiki/web_ui.py", line 165, in process_request Code fragment:
    1. else:
    2. format = req.args.get('format')
    3. if format:
    4. Mimeview(self.env).send_converted(req, 'text/x-trac-wiki',
    5. versioned_page.text,
    6. format, versioned_page.name)
    7. return self._render_view(req, versioned_page)
    8. # ITemplateProvider methods
    9. def get_htdocs_dirs(self):
    Local variables: Name Value action 'view' format u'odt' old_version None page <trac.wiki.model.WikiPage object at 0xa5ee2d0c> pagename u'WikiStart' req <Request "GET u'/wiki/WikiStart'"> self <trac.wiki.web_ui.WikiModule object at 0xa26034c> version None versioned_page <trac.wiki.model.WikiPage object at 0xa604578c>
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/mimeview/api.py", line 961, in send_converted Code fragment:
    1. """Helper method for converting content and sending it directly.
    2. selector can be either a key or a MIME Type."""
    3. from trac.web import RequestDone
    4. content, output_type, ext = self.convert_content(req, in_type,
    5. content, selector)
    6. if isinstance(content, unicode):
    7. content = content.encode('utf-8')
    8. req.send_response(200)
    9. req.send_header('Content-Type', output_type)
    10. req.send_header('Content-Length', len(content))
    Local variables: Name Value RequestDone <class 'trac.web.api.RequestDone'> content u'\r\n= Welcome to the vfree.tv project wikipages =\r\n\r\nThese pages ... filename u'WikiStart' in_type 'text/x-trac-wiki' req <Request "GET u'/wiki/WikiStart'"> selector u'odt' self <trac.mimeview.api.Mimeview object at 0xa04ab6c>
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/mimeview/api.py", line 669, in convert_content Code fragment:
    1. 'to %(new)s', old=mimetype, new=key))
    2. # First successful conversion wins
    3. for ck, name, ext, input_mimettype, output_mimetype, quality, \
    4. converter in candidates:
    5. output = converter.convert_content(req, mimetype, content, ck)
    6. if not output:
    7. continue
    8. return (output[0], output[1], ext)
    9. raise TracError(_('No available MIME conversions from %(old)s to '
    10. '%(new)s', old=mimetype, new=key))
    Local variables: Name Value c ('odt', 'OpenDocument', 'odt', 'text/x-trac-wiki', ... candidates [('odt', 'OpenDocument', 'odt', 'text/x-trac-wiki', ... ck 'odt' content u'\r\n= Welcome to the vfree.tv project wikipages =\r\n\r\nThese pages ... converter <odtexport.odtexport.ODTExportPlugin object at 0xa17a5cc> ext 'odt' filename None full_mimetype 'text/x-trac-wiki' input_mimettype 'text/x-trac-wiki' key u'odt' mimetype 'text/x-trac-wiki' name 'OpenDocument' output_mimetype 'application/vnd.oasis.opendocument.text' quality 5 req <Request "GET u'/wiki/WikiStart'"> self <trac.mimeview.api.Mimeview object at 0xa04ab6c> url None
  • File "build/bdist.linux-i686/egg/odtexport/odtexport.py", line 72, in convert_content Local variables: Name Value content u'\r\n= Welcome to the vfree.tv project wikipages =\r\n\r\nThese pages ... html '<?xml version="1.0"?>\n<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 ... input_type 'text/x-trac-wiki' odtfile <odtexport.odtexport.ODTFile object at 0xa0441cc> output_type 'odt' page_name u'WikiStart' req <Request "GET u'/wiki/WikiStart'"> self <odtexport.odtexport.ODTExportPlugin object at 0xa17a5cc>
  • File "build/bdist.linux-i686/egg/odtexport/odtexport.py", line 173, in import_xhtml Local variables: Name Value self <odtexport.odtexport.ODTFile object at 0xa0441cc> xhtml '<?xml version="1.0"?>\n<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 ...
  • File "build/bdist.linux-i686/egg/odtexport/odtexport.py", line 185, in xhtml_to_odt Local variables: Name Value self <odtexport.odtexport.ODTFile object at 0xa0441cc> transform <lxml.etree.XSLT object at 0xa28826c> xhtml <Element {http://www.w3.org/1999/xhtml}html at a268b94> xsl_dir '/home/projects/v3tv/.egg-cache/OdtExportPlugin-0.1-py2.5.egg-tmp/odtexport ... xslt_doc <lxml.etree._ElementTree object at 0xa2302cc>

File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py", line 450, in _dispatch_request

dispatcher.dispatch(req)

File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py", line 206, in dispatch

resp = chosen_handler.process_request(req)

File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/wiki/web_ui.py", line 165, in process_request

format, versioned_page.name)

File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/mimeview/api.py", line 961, in send_converted

content, selector)

File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/mimeview/api.py", line 669, in convert_content

output = converter.convert_content(req, mimetype, content, ck)

File "build/bdist.linux-i686/egg/odtexport/odtexport.py", line 72, in convert_contentFile "build/bdist.linux-i686/egg/odtexport/odtexport.py", line 173, in import_xhtmlFile "build/bdist.linux-i686/egg/odtexport/odtexport.py", line 185, in xhtml_to_odt

comment:3 Changed 5 years ago by abompard

Hmm, I have a server with lxml 2.1 around, I managed to reproduce your bug, but my commit fixed it here. Are you sure it's not a cache problem ? Try removing the plugin completely, restarting the server, putting it back, and restarting the server again.

I'm not sure how I should debug this... On the error page, you should have a traceback, and a button "switch to plain text view". Please click on the button and post the plain text traceback here please.

Thanks.

comment:4 Changed 5 years ago by tomw@…

That's exactly what I did. Removed the directory completely, unzipped the download, restarted the server. Same result again. Here are the files in plain text ( abit difficult to read though)

br, Thomas

ile "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py", line 450, in _dispatch_request

dispatcher.dispatch(req)

File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py", line 206, in dispatch

resp = chosen_handler.process_request(req)

File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/wiki/web_ui.py", line 165, in process_request

format, versioned_page.name)

File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/mimeview/api.py", line 961, in send_converted

content, selector)

File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/mimeview/api.py", line 669, in convert_content

output = converter.convert_content(req, mimetype, content, ck)

File "build/bdist.linux-i686/egg/odtexport/odtexport.py", line 72, in convert_contentFile "build/bdist.linux-i686/egg/odtexport/odtexport.py", line 173, in import_xhtmlFile "build/bdist.linux-i686/egg/odtexport/odtexport.py", line 185, in xhtml_to_odt

comment:5 Changed 5 years ago by abompard

OK, I've updated the SVN again, could you update your copy ? Thanks.

And now I know why the cache was playing tricks on me : it's actually my browser's cache which was getting in the way. When you reload your page, can you bypass the cache (in Firefox it's Ctrl+Shift+R) please ? It did bit me for quite some time until I found this trick...

If you still have the bug, I'd be interested in the plain text traceback again please. You can enclose it in 3 curly braces to keep the formatting, like that:

{{{
 traceback
}}}

comment:6 Changed 5 years ago by tomw@…

Hi, unfortunately I'm still getting the same error message after updating, restarting and reloading (even with Ctrl+Shift+R). Pleas see the attached traceback files.

Thanks for your support,

br, Thomas

File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py", line 450, in _dispatch_request
  dispatcher.dispatch(req)
File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py", line 206, in dispatch
  resp = chosen_handler.process_request(req)
File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/wiki/web_ui.py", line 165, in process_request
  format, versioned_page.name)
File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/mimeview/api.py", line 961, in send_converted
  content, selector)
File "/usr/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/mimeview/api.py", line 669, in convert_content
  output = converter.convert_content(req, mimetype, content, ck)
File "build/bdist.linux-i686/egg/odtexport/odtexport.py", line 72, in convert_contentFile "build/bdist.linux-i686/egg/odtexport/odtexport.py", line 173, in import_xhtmlFile "build/bdist.linux-i686/egg/odtexport/odtexport.py", line 185, in xhtml_to_odt

comment:7 Changed 5 years ago by abompard

OK, I'll try other ways to get information.

  • I need your lxml version. You should be able get it with this command :
    grep ^Version /usr/lib/python2.*/site-packages/lxml*.egg-info/PKG-INFO
    
  • How did you install lxml ? With the distribution's packages or by another mean ?
  • Which distribution are you running Trac on ?
  • Please give me the output of:
    python -c "import lxml.etree as etree; print etree.XSLT.strparam"
    

Thanks

comment:8 Changed 5 years ago by tomw@…

Hi, here we go: The PKG-INFO does not exist in the /usr/lib/python2.5/site-packages directory. The lxml-2.1.1.egg-info contains:

Metadata-Version: 1.0
Name: lxml
Version: 2.1.1
...
  • python-lxml was installed from the packages via aptitude, I'm running Debian 5.0 Server
  • here's the output of the import statement (as expected):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: type object 'lxml.etree.XSLT' has no attribute 'strparam'

Hope that helps you to trace the issue.

best,

Thomas

comment:9 Changed 5 years ago by abompard

OK, that helps, thanks. Could you run one more command for me please ?

python -c "import lxml.etree as etree; print hasattr(etree.XSLT, 'strparam')"

That's the test I use to enter the lxml "old version" compatibility mode which fixed it for me. On my machine it returns false (no strparam attribute), but on yours it seems to return true, can you confirm it ?

Thanks.

comment:10 Changed 5 years ago by tomw@…

Hi, to make it even a bit more complicated:

# python -c "import lxml.etree as etree; print hasattr(etree.XSLT,
>  'strparam')"
False

br, Thomas

comment:11 Changed 5 years ago by abompard

OK, I don't understand what's going on. My code checks this very function, and if false, goes to the "compatibility mode".

I'm pretty sure now that it's a cache problem. Maybe apache uses an egg cache or something. Could you post the relevant apache config section please ?

comment:12 Changed 5 years ago by tomw@…

Hmm, of course there is the standard setting:

SetEnv PYTHON_EGG_CACHE /home/mydir/.python-eggs

in the apache.conf. However, switching it off, restarting the web server, reloading the page leads to exactly the same error, which is no surprise at it only contains the Genshi package and therefore should not impact anything else.

br, Thomas

comment:13 Changed 5 years ago by abompard

Is your trac instance accessible from the internet ? Could you give me a temporary access ? I'm running out of ideas...

comment:14 Changed 5 years ago by tomw@…

Unfortunately that's not possible. The trac instance is not accessible from the internet. The alternative would be to install lxml 2.2. I'll try to do that and then let's see what happens.

br, Thomas

comment:15 Changed 5 years ago by tomw@…

That finally did it. It's not resolving the original issue, but at least it works now. Thanks for your support.

Thomas

comment:16 Changed 5 years ago by abompard

To make sure I just installed Debian Lenny in VirtualBox, installed trac, python-lxml, python-imaging, python-utidylib and exported a wiki page : it worked fine. I'm pretty sure that somehow the old code is running.

At some point I change the version from 0.1 to 0.2, maybe it's that. Please check that you don't have both eggs installed in your plugins dir.

comment:17 Changed 5 years ago by abompard

  • Resolution set to fixed
  • Status changed from reopened to closed

Add Comment

Modify Ticket

Action
as closed The owner will remain abompard.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.