Ticket #3590 (closed defect: fixed)

Opened 6 months ago

Last modified 6 months ago

Error: Macro Image(foo.png) failed

Reported by: anonymous Assigned to: diorgenes
Priority: normal Component: TracWikiToPdfPlugin
Severity: major Keywords:
Cc: Trac Release: 0.11

Description

Hello,

I've just installed Trac and TracWikiToPdfPlugin 2.2. When I click on WikiToPdf on a page with images, the following error appears in the generated PDF instead of displaying the images:

Error: Macro Image(foo.png) failed
sequence item 0: expected string, NoneType found

Here is the trace from the Trac logs:

2008-08-21 15:23:45,760 Trac[formatter] DEBUG: Executing Wiki macro Image by provider <trac.wiki.macros.ImageMacro object at 0x4292f32c>
2008-08-21 15:23:45,764 Trac[formatter] ERROR: Macro Image(foo.png) failed
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/wiki/formatter.py", line 468, in _macro_formatter
    return macro.process(args, in_paragraph=True)
  File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/wiki/formatter.py", line 179, in process
    text = self.processor(text)
  File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/wiki/formatter.py", line 166, in _macro_processor
    text)
  File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/wiki/macros.py", line 425, in expand_macro
    if attachment and 'ATTACHMENT_VIEW' in formatter.perm(attachment):
  File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/perm.py", line 523, in has_permission
    return self._has_permission(action, resource)
  File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/perm.py", line 536, in _has_permission
    decision = PermissionSystem(self.env). \
  File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/perm.py", line 431, in check_permission
    self.log.debug("No policy allowed %s performing %s on %r" %
  File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/resource.py", line 111, in __repr__
    return '<Resource %r>' % (', '.join(reversed(path)))
TypeError: sequence item 0: expected string, NoneType found

Here is my System Information

Trac: 0.11.1
Python: 2.4.1 (#1, Sep 25 2007, 16:58:32) [GCC 4.0.2 20050901 (prerelease) (SUSE Linux)]
setuptools: 0.6c8
SQLite: 3.2.2
pysqlite: 2.2.2
Genshi: 0.5.1
mod_python: < 3.2
Subversion: 1.2.3 (r15833)
jQuery: 1.2.6

Thanks for your support,

RB

Attachments

Change History

08/21/08 22:17:40 changed by diorgenes

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

Hi

This is not error!

Your code page:

[[Image(foo.png)]]

This is correct code page:

[[Image(PageNameWiki:foo.png)]]

(follow-up: ↓ 3 ) 08/21/08 23:31:50 changed by anonymous

Ok My bad, I thought [[Image(foo.png)]] was a *normal* way to include images in the wiki pages. I've still trouble to make the images displayed in the generated PDF. Could you please explain me what do you mean by

# base_dir is the Apache DocumentRoot, It is need to get PDF files with images.
base_dir = /path/to/DocumentRoot

Should base_dir be set with the path on my server or the link in my browser? Anyway, both eg: /var/www/htdocs or eg: http://mydomain.com don't work. Should I change another configuration lines in my trac.ini?

Thanks,

RB

(in reply to: ↑ 2 ) 08/22/08 14:25:04 changed by diorgenes

Replying to anonymous:

Ok My bad, I thought [[Image(foo.png)]] was a *normal* way to include images in the wiki pages. I've still trouble to make the images displayed in the generated PDF. Could you please explain me what do you mean by {{{ # base_dir is the Apache DocumentRoot?, It is need to get PDF files with images. base_dir = /path/to/DocumentRoot }}} Should base_dir be set with the path on my server or the link in my browser? Anyway, both eg: /var/www/htdocs or eg: http://mydomain.com don't work. Should I change another configuration lines in my trac.ini? Thanks, RB


Hi, my configurations:

[wikitopdf]
base_dir = /var/www
pathtocover = /var/www/trac11/htdocs/cover
link = http://server/trac11
folder_name = trac11

Regards

Diorgenes F. Grzesiuk

(follow-up: ↓ 5 ) 08/22/08 20:18:02 changed by anonymous

FYI.

I think this point should be rethought, since trac is not always under the DocumentRoot directory.

For example, my trac project is under /var/trac/myproject, and it is configured in a way that I access it using http://myserver.com/trac.

It means that when displayed in the wiki, the <img> elements are pointing to something like trac/raw-attachment/wiki/mypage/myimage.png.

So, when you tranform the wiki text into the html page by replacing raw-attachment with attachments and adding before the variable base_dir (let's say /var), it looks for the image in the server directory var/trac/attachments/wiki/mypage/myimage.png.

It doesn't work since my image is in the directory /var/trac/'''myproject'''/attachments/wiki/mypage/myimage.png.

In your case, it just works fine since the <img> element in the wiki is trac11/raw_attachment/wiki/mypage/myimage.png. That fits with your server directory /var/www/trac11/attachments/etc.

I fixed it by modifying the source code of the plugin. It think it's an issue that should be considered.

(in reply to: ↑ 4 ) 08/22/08 22:41:34 changed by diorgenes

Replying to anonymous:

FYI. I think this point should be rethought, since trac is not always under the DocumentRoot directory. For example, my trac project is under /var/trac/myproject, and it is configured in a way that I access it using http://myserver.com/trac. It means that when displayed in the wiki, the <img> elements are pointing to something like trac/raw-attachment/wiki/mypage/myimage.png. So, when you tranform the wiki text into the html page by replacing raw-attachment with attachments and adding before the variable base_dir (let's say /var), it looks for the image in the server directory var/trac/attachments/wiki/mypage/myimage.png. It doesn't work since my image is in the directory /var/trac/'''myproject'''/attachments/wiki/mypage/myimage.png. In your case, it just works fine since the <img> element in the wiki is trac11/raw_attachment/wiki/mypage/myimage.png. That fits with your server directory /var/www/trac11/attachments/etc. I fixed it by modifying the source code of the plugin. It think it's an issue that should be considered.

Hi

Ok, What you like change it? Do you have a path file? I was many tests, but I wasn't found error equal yours...

Regards

Diorgenes F. Grzesiuk

08/25/08 19:37:18 changed by anonymous

I think that basically, you should add the base_dir value before attachments/wiki/mypage/myimage.png and not before trac/attachments/wiki/mypage/myimage.png as it is now.

I really like this pluggin. I've got some ideas on how to make it involve, like for example:


Add/Change #3590 (Error: Macro Image(foo.png) failed)




Change Properties
Action