[IMP] parse description html to change image src to [module]/static/description/image_url

bzr revid: chm@openerp.com-20130530135147-oij26myykrngrig1
This commit is contained in:
Christophe Matthieu 2013-05-30 15:51:47 +02:00
parent fee9494b4b
commit 4bf6a7ea4c
1 changed files with 7 additions and 1 deletions

View File

@ -32,6 +32,7 @@ import urllib
import urllib2
import zipfile
import zipimport
import lxml.html
try:
from cStringIO import StringIO
@ -156,7 +157,12 @@ class module(osv.osv):
if path:
desc_file = tools.file_open(path, 'rb')
try:
res[module.id] = desc_file.read()
doc = desc_file.read()
html = lxml.html.document_fromstring(doc)
for element in html.iterlinks():
if element.get('src'):
element.set('src', "%s/static/description/%s" % (module.name, element.get('src')))
res[module.id] = lxml.html.tostring(html)
finally:
desc_file.close()
else: