AttributeError: 'etree._ElementTree' object has no attribute

AttributeError: 'etree._ElementTree' object has no attribute

Postby joolsr » Tue Feb 02, 2010 4:13 pm

Hi

I'm using the script from here http://opensourceconsulting.wordpress.c ... or-ubuntu/ with OpenOffice.org Reporting installed as part of the script on a 8.0.4 Ubuntu virtual machine. The script pulls in all required python modules such as relatorio. I am using the stable install, ie using 5.0.6

But I still get the error above which is odd, as the VM is a completely fresh install ..

There is mention in these forums viewtopic.php?f=11&t=43 that I might need a newer lxml but also in the fourms it implies that a different call should be used.

Please can you help ? I have also posted this in the comments section of the script I have used to make them aware that a default install doesnt quite seem to work.

Julian
joolsr
 
Posts: 7
Joined: Tue Feb 02, 2010 4:07 pm

Re: AttributeError: 'etree._ElementTree' object has no attribute

Postby sraps » Tue Feb 02, 2010 8:54 pm

Could you please past whole error message, as it seems, that end has been cut off in the Subject line of forum...

Kaspars
sraps
 
Posts: 403
Joined: Mon May 04, 2009 10:04 pm

Re: AttributeError: 'etree._ElementTree' object has no attribute

Postby joolsr » Sat Feb 06, 2010 11:42 pm

Hi

I never saw your reply, which is why I didnt reply earlier ...

Here is the full error message, hope you can help ..

Julian

Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/openerp-server/service/web_services.py", line 683, in go
(result, format) = obj.create(cr, uid, ids, datas, context)
File "/usr/lib/python2.5/site-packages/openerp-server/addons/report_openoffice/report_openoffice.py", line 290, in create
return fnct(cr, uid, ids, data, report_xml, context)
File "/usr/lib/python2.5/site-packages/openerp-server/addons/report_openoffice/report_openoffice.py", line 199, in create_relatorio_report
basic = Template(source=None, filepath=odt_path)
File "/usr/lib/python2.5/site-packages/relatorio-0.5.3-py2.5.egg/relatorio/templates/opendocument.py", line 196, in __init__
encoding, lookup, allow_exec)
File "/usr/lib/python2.5/site-packages/Genshi-0.5.1-py2.5-linux-i686.egg/genshi/template/base.py", line 377, in __init__
self.stream = list(self._prepare(self._parse(source, encoding)))
File "/usr/lib/python2.5/site-packages/relatorio-0.5.3-py2.5.egg/relatorio/templates/opendocument.py", line 208, in _parse
content = template._parse(self.insert_directives(content), encoding)
File "/usr/lib/python2.5/site-packages/relatorio-0.5.3-py2.5.egg/relatorio/templates/opendocument.py", line 263, in insert_directives
self._escape_values(tree)
File "/usr/lib/python2.5/site-packages/relatorio-0.5.3-py2.5.egg/relatorio/templates/opendocument.py", line 637, in _escape_values
for element in tree.iter():
AttributeError: 'etree._ElementTree' object has no attribute 'iter'
joolsr
 
Posts: 7
Joined: Tue Feb 02, 2010 4:07 pm

Re: AttributeError: 'etree._ElementTree' object has no attribute

Postby sraps » Mon Feb 08, 2010 11:09 am

Hi!
Seems that you have an outdated lxml ( http://codespeak.net/lxml/ ) or libxml version. Obviously you have it prior to 2.0, because iter method were introduced into it in end of 2007 (v2.0). Please take a look what version do you have.

It seems that some operating systems have it outdated in their standard packages. Could you tell what OS and version of it do you have, so we can update our installation manual.

Kaspars
sraps
 
Posts: 403
Joined: Mon May 04, 2009 10:04 pm

Re: AttributeError: 'etree._ElementTree' object has no attribute

Postby joolsr » Mon Feb 08, 2010 12:55 pm

I'm using Ubuntu 8.04 and have only lxml 1.3.6 installed

I'll see if there's a PPA for lxml otherwise perhaps I'll try Ubuntu 9.10 and the script.
joolsr
 
Posts: 7
Joined: Tue Feb 02, 2010 4:07 pm

Re: AttributeError: 'etree._ElementTree' object has no attribute

Postby joolsr » Mon Feb 08, 2010 1:04 pm

Ok

I used this PPA deb http://ppa.launchpad.net/mediawiki-exte ... ppa/ubuntu hardy main to upgrade lxml to 2.1.5.

But now i get a different error -

<type 'exceptions.KeyError'>: u'odt'
args = (u'odt',)
message = u'odt'

I remember I had this error a while back, when i used easy_install to install lxml (thinking that somehow my lxml hadnt been upgraded properly)

Hope you can help.
joolsr
 
Posts: 7
Joined: Tue Feb 02, 2010 4:07 pm

Re: AttributeError: 'etree._ElementTree' object has no attribute

Postby sraps » Mon Feb 08, 2010 1:44 pm

Please provide complete error message and what do you do when you receive it?
sraps
 
Posts: 403
Joined: Mon May 04, 2009 10:04 pm

Re: AttributeError: 'etree._ElementTree' object has no attribute

Postby joolsr » Mon Feb 08, 2010 2:09 pm

Hello

I get the error below when I click on my Sample Report whilst viewing a Partner

Julian

<type 'exceptions.KeyError'> Python 2.5.2: /usr/bin/python
Mon Feb 8 11:08:31 2010

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
/usr/lib/python2.5/site-packages/CherryPy-3.1.2-py2.5.egg/cherrypy/_cprequest.py in respond(self=<cherrypy._cprequest.Request object at 0x8de264c>, path_info='/form/action')
604 if self.handler:
605 self.stage = 'handler'
606 cherrypy.response.body = self.handler()
607
608 self.stage = 'before_finalize'
global cherrypy = <module 'cherrypy' from '/usr/lib/python2.5/site.../CherryPy-3.1.2-py2.5.egg/cherrypy/__init__.pyc'>, cherrypy.response = <cherrypy._ThreadLocalProxy object at 0x840486c>, cherrypy.response.body = [], self = <cherrypy._cprequest.Request object at 0x8de264c>, self.handler = <cherrypy._cpdispatch.LateParamPageHandler object at 0x8de59ac>
/usr/lib/python2.5/site-packages/CherryPy-3.1.2-py2.5.egg/cherrypy/_cpdispatch.py in __call__(self=<cherrypy._cpdispatch.LateParamPageHandler object at 0x8de59ac>)
23 def __call__(self):
24 try:
25 return self.callable(*self.args, **self.kwargs)
26 except TypeError, x:
27 test_callable_spec(self.callable, self.args, self.kwargs)
self = <cherrypy._cpdispatch.LateParamPageHandler object at 0x8de59ac>, self.callable = <function action at 0x8fb5ed4>, self.args = (), self.kwargs = {'_terp_action': '348', '_terp_id': '9', '_terp_model': 'res.partner'}
/usr/lib/python2.5/site-packages/openerp_web-5.0.6-py2.5.egg/openerp/controllers/base.py in wrapper(*args=(), **kw={'_terp_action': '348', '_terp_id': '9', '_terp_model': 'res.partner'})
120 # User is logged in; allow access
121 clear_login_fields(kw)
122 return fn(*args, **kw)
123 else:
124 # User isn't logged in yet.
fn = <bound method Form.action of <openerp.controllers.form.Form object at 0x8c5fa0c>>, args = (), kw = {'_terp_action': '348', '_terp_id': '9', '_terp_model': 'res.partner'}
/usr/lib/python2.5/site-packages/openerp_web-5.0.6-py2.5.egg/openerp/tools/expose.py in func_wrapper(*args=(<openerp.controllers.form.Form object at 0x8c5fa0c>,), **kw={'_terp_action': '348', '_terp_id': '9', '_terp_model': 'res.partner'})
202 def func_wrapper(*args, **kw):
203
204 res = func(*args, **kw)
205
206 if format == 'json' or (allow_json and 'allow_json' in cherrypy.request.params):
global res = '/usr/lib/python2.5/site-packages/openerp_web-5.0.../openerp/widgets/tinycalendar/templates/week.mako', func = <function action at 0x898f33c>, args = (<openerp.controllers.form.Form object at 0x8c5fa0c>,), kw = {'_terp_action': '348', '_terp_id': '9', '_terp_model': 'res.partner'}
/usr/lib/python2.5/site-packages/openerp_web-5.0.6-py2.5.egg/openerp/controllers/form.py in action(self=<openerp.controllers.form.Form object at 0x8c5fa0c>, **kw={'_terp_action': '348', '_terp_id': '9', '_terp_model': 'res.partner'})
876
877 from openerp.controllers import actions
878 return actions.execute(action, model=params.model, id=id, ids=ids, report_type='pdf')
879
880 @expose()
actions = <module 'openerp.controllers.actions' from '/usr...5.0.6-py2.5.egg/openerp/controllers/actions.pyc'>, actions.execute = <function execute at 0x8991b8c>, action = {'attachment': False, 'attachment_use': False, 'auto': True, 'context': {}, 'domain': [], 'groups_id': [], 'header': True, 'id': 348, 'model': u'res.partner', 'multi': False, ...}, model undefined, params = {'_terp_id': 9, '_terp_action': 348, '_terp_model': 'res.partner'}, params.model = 'res.partner', id = 9, ids = [9], report_type undefined
/usr/lib/python2.5/site-packages/openerp_web-5.0.6-py2.5.egg/openerp/controllers/actions.py in execute(action={'attachment': False, 'attachment_use': False, 'auto': True, 'context': {}, 'domain': [], 'groups_id': [], 'header': True, 'id': 348, 'model': u'res.partner', 'multi': False, ...}, **data={'id': 9, 'ids': [9], 'model': 'res.partner', 'report_type': 'pdf'})
279
280 elif action['type']=='ir.actions.report.xml':
281 return execute_report(action['report_name'], **data)
282
283 elif action['type']=="ir.actions.act_url":
global execute_report = <function execute_report at 0x8991b54>, action = {'attachment': False, 'attachment_use': False, 'auto': True, 'context': {}, 'domain': [], 'groups_id': [], 'header': True, 'id': 348, 'model': u'res.partner', 'multi': False, ...}, data = {'id': 9, 'ids': [9], 'model': 'res.partner', 'report_type': 'pdf'}
/usr/lib/python2.5/site-packages/openerp_web-5.0.6-py2.5.egg/openerp/controllers/actions.py in execute_report(name=u'sample.res.partner', **data={'id': 9, 'ids': [9], 'model': 'res.partner', 'report_type': 'pdf'})
175 cherrypy.response.headers['Content-Disposition'] = 'filename="' + report_name + '.' + report_type + '"';
176
177 return _print_data(val)
178
179 except rpc.RPCException, e:
global _print_data = <function _print_data at 0x8991b1c>, val = {'format': u'odt', 'result': u'UEsDBBQAAAgAAHNoQjxexjIMJwAAACcAAAAIAAAAbWltZXR5...bWFuaWZlc3QueG1sUEsFBgAAAAAeAB4A3AcAAM9/AAAAAA==\n', 'state': True}
/usr/lib/python2.5/site-packages/openerp_web-5.0.6-py2.5.egg/openerp/controllers/actions.py in _print_data(data={'format': u'odt', 'result': u'UEsDBBQAAAgAAHNoQjxexjIMJwAAACcAAAAIAAAAbWltZXR5...bWFuaWZlc3QueG1sUEsFBgAAAAAeAB4A3AcAAM9/AAAAAA==\n', 'state': True})
127 content = base64.decodestring(data['result'])
128
129 cherrypy.response.headers['Content-Type'] = PRINT_FORMATS[data['format']]
130 return content
131
global cherrypy = <module 'cherrypy' from '/usr/lib/python2.5/site.../CherryPy-3.1.2-py2.5.egg/cherrypy/__init__.pyc'>, cherrypy.response = <cherrypy._ThreadLocalProxy object at 0x840486c>, cherrypy.response.headers = {'Date': 'Mon, 08 Feb 2010 11:08:30 GMT', 'Conte...filename="Test.odt"', 'Server': 'CherryPy/3.1.2'}, global PRINT_FORMATS = {'doc': 'application/vnd.ms-word', 'html': 'text/html', 'pdf': 'application/pdf', 'sxw': 'application/vnd.sun.xml.writer'}, data = {'format': u'odt', 'result': u'UEsDBBQAAAgAAHNoQjxexjIMJwAAACcAAAAIAAAAbWltZXR5...bWFuaWZlc3QueG1sUEsFBgAAAAAeAB4A3AcAAM9/AAAAAA==\n', 'state': True}

<type 'exceptions.KeyError'>: u'odt'
args = (u'odt',)
message = u'odt'
joolsr
 
Posts: 7
Joined: Tue Feb 02, 2010 4:07 pm

Re: AttributeError: 'etree._ElementTree' object has no attribute

Postby sraps » Mon Feb 08, 2010 4:21 pm

It seems, that there is not "OpenOffice - pdf output" type set for this particular report....

Kaspars
sraps
 
Posts: 403
Joined: Mon May 04, 2009 10:04 pm

Re: AttributeError: 'etree._ElementTree' object has no attribute

Postby inaki » Mon Feb 08, 2010 4:33 pm

According to REQUIRES.txt file, report-openoffice requires two packages: 1) relatorio 2)openoffice-python

The second one is not included in the openerp allinone installer for ubuntu. Procedure:

8.04 : sudo easy_install openoffice-python
9.10 : sudo apt-get install -y python-openoffice

BTW, I’ve figured out how to install python lxml 2.2.4 on Ubuntu 8.04:

sudo apt-get install -y libxml2-dev libxslt1-dev
sudo easy_install “lxml>2.0″

On the other hand, openoffice has to be running in headless mode to generate pdf documents (check it out by "ps uaxww | grep -i soffice"). The allinone installer provides a startup script "sudo /etc/init.d/openoffice stop/start"
inaki
 
Posts: 7
Joined: Mon Feb 08, 2010 4:28 pm

Next

Return to Aeroo Reports & OpenOffice.org Reporting Engine

cron
Copyright © 2001 Alistek Ltd., ALL RIGHTS RESERVED