Modify

Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#3590 closed defect (fixed)

Error: Macro Image(foo.png) failed

Reported by: anonymous Owned by: Diorgenes Felipe Grzesiuk
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 (0)

Change History (8)

comment:1 Changed 16 years ago by Diorgenes Felipe Grzesiuk

Resolution: fixed
Status: newclosed

Hi

This is not error!

Your code page:

[[Image(foo.png)]]

This is correct code page:

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

comment:2 Changed 16 years ago 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

comment:3 in reply to:  2 Changed 16 years ago by Diorgenes Felipe Grzesiuk

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

comment:4 Changed 16 years ago 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.

comment:5 in reply to:  4 Changed 16 years ago by Diorgenes Felipe Grzesiuk

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

comment:6 Changed 16 years ago 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:

comment:7 Changed 16 years ago by anonymous

Hi there,

I found a solution for my trac 0.11.3 instance on ubuntu 8.04 with apache2 (single project):

In order to get a correct path for htmldoc to the images, set "PythonOption TracUriRoot /trac/wiki" File: /etc/apache2/sites-available/trac

<Location /trac>
   SetHandler mod_python
   PythonHandler trac.web.modpython_frontend
   PythonPath "sys.path + ['/usr/share/trac']"
   PythonOption TracEnv /var/trac/wiki
   PythonOption TracUriRoot /trac/wiki
   AuthType Basic
   AuthName "Trac"
   AuthUserFile /etc/apache2/trac.passwd
#   Require valid-user
</Location>

File: /var/trac/wiki/conf/trac.ini

...
[wikitopdf]
base_dir = /var
folder_name = trac
link = http://localhost/trac/wiki
pathtocover = /var/trac/wiki/cover
titlefile = 
...

base_dir = /var

Now i've tested the following Image-Macro's in some wiki-sides: 1 .No image "basic-workflow.png" attached to TicketSystem

2.No image "basic-workflow.png" attached to TicketSystem

3.No image "basic-workflow.png" attached to Ticket #3590

The first two are working the thrid throws an error-print-out in the PDF.

Just my 2 cents to this Ticket. If this info is usefull it's just helpfull to point this out at the installation / configuration notice of this very cool Plugin.

sincerely

Ice

comment:8 Changed 14 years ago by anonymous

Are there no solutions to this ?

I've tried several configurations but no images so far, please clarify the paths we should use to get images in pdf's

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Diorgenes Felipe Grzesiuk.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.