Ticket #1736 (closed defect: fixed)

Opened 6 years ago

Last modified 4 years ago

getting it to work under Python 2.5

Reported by: coenen.rob@gmail.com Assigned to: cdevienne
Priority: high Component: PageToOdtPlugin
Severity: blocker Keywords: python 2.5
Cc: Trac Release: 0.10

Description

First my plugin did not work at all (it did not show uo in WebAdmin -> Plugins) Then I figured that b/c I am using Python 2.5 I need to change the import statement si replaced in pagetoodt.py

#import cElementTree as ElementTree?

with

from xml.etree.ElementTree? import Element, ElementTree? # python 2.5

note that I am a total Python newbie... at least the plugin shows up in the WebAdmin -> Plugins menu now and it is activated... .but now I have the same problem as described above.

But now I get this error:

Python Traceback

Traceback (most recent call last):
  File "/var/lib/python-support/python2.5/trac/web/main.py", line 387, in dispatch_request
    dispatcher.dispatch(req)
  File "/var/lib/python-support/python2.5/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "/var/lib/python-support/python2.5/trac/wiki/web_ui.py", line 134, in process_request
    page.text, format, page.name)
  File "/var/lib/python-support/python2.5/trac/mimeview/api.py", line 604, in send_converted
    content, selector)
  File "/var/lib/python-support/python2.5/trac/mimeview/api.py", line 384, in convert_content
    output = converter.convert_content(req, mimetype, content, ck)
  File "build/bdist.linux-i686/egg/pagetoodt/pagetoodt.py", line 30, in convert_content
    archive = zipfile.ZipFile(self.template_filename, 'r')
  File "zipfile.py", line 339, in __init__
    self.fp = open(file, modeDict[mode])
IOError: [Errno 2] No such file or directory: u'/var/www/trac/pwc/attachments/wiki/PageToOdtStyles/empty.odt'

Attachments

Change History

07/04/07 20:14:54 changed by coenen.rob@gmail.com

  • status changed from new to closed.
  • resolution set to fixed.

here is the fix (tested and verified) to get the plugin working with Python 2.5

replace in pagetoodt.py

import cElementTree as ElementTree

with

try:
	# python 2.5 way of life :)
	import xml.etree.cElementTree as ElementTree
except:
	# python 2.4
	import cElementTree as ElementTree 

Don't forget to

now it should work

09/20/07 22:13:53 changed by JasonWinnebeck

  • status changed from closed to reopened.
  • resolution deleted.

This didn't actually appear to be checked in?

09/22/07 10:20:38 changed by cdevienne

  • status changed from reopened to closed.
  • resolution set to fixed.

Applied in r2650.

Thanks for the patch and sorry for the delay.

09/22/07 18:41:37 changed by anonymous

If this makes the plugin stable and work on 0.11, let's add the 0.11 tag to the plugin page to advertise 0.11 support.

09/22/07 18:45:54 changed by JasonWinnebeck

Wow, wrong ticket, sorry I was really off in another world on that one. This ticket is adding Python 2.5 support.


Add/Change #1736 (getting it to work under Python 2.5)




Change Properties
Action