Modify

Opened 6 years ago

Closed 5 years ago

#3572 closed defect (fixed)

AttributeError: 'NoneType' object has no attribute 'applyStylesheet'

Reported by: scratcher Owned by: FilipeCorreia
Priority: normal Component: Page2DocbookPlugin
Severity: blocker Keywords:
Cc: Trac Release: 0.11

Description

Hello!

Trac 0.11 installation under Windows,
uTidyLib was taken from this page: http://utidylib.berlios.de/
LibXml2 and LibXSLT were taken from this site: http://users.skynet.be/sbi/libxml-python/

Plugin generates the error: AttributeError: 'NoneType' object has no attribute 'applyStylesheet', see screenshot attached.
Thanks!

Attachments (3)

error.png (44.3 KB) - added by scratcher 6 years ago.
stack trace
error.2.png (82.0 KB) - added by scratcher 6 years ago.
stack trace
pagetodocbook.py (2.9 KB) - added by scratcher 6 years ago.
fixed version for Windows environment

Download all attachments as: .zip

Change History (17)

Changed 6 years ago by scratcher

stack trace

Changed 6 years ago by scratcher

stack trace

comment:1 follow-ups: Changed 6 years ago by FilipeCorreia

Sounds some of the stylesheet files are not being found.
Can you please confirm all of the files were correctly extracted from the egg?
Namely, that you have several html and xsl files under c:\trac\plugins\pagetodocbook-0.6.2.egg\pagetodocbook\data\html2db

comment:2 in reply to: ↑ 1 Changed 6 years ago by scratcher

In c:\trac\plugins\ I see pagetodocbook-0.6.2.egg (zip archive), directory inside it you mentioned above contains following files:
ar01s02.html
ar01s03.html
ar01s04.html
ar01s05.html
ar01s06.html
ar01s07.html
ar01s08.html
ar01s09.html
ar01s10.html
build.xml
example.xsl
extract-section.xsl
extract-toc.xsl
html2db.xsl
html2db-utils.xsl
index.html
index.src.html
index.xml
LICENSE.txt
tidy.properties

There is no directories (should they be there?) pagetodocbook-0.6.2.egg\pagetodocbook\data\html2db in c:\Trac\plugins. I've installed .egg via Trac administration panel.

comment:3 in reply to: ↑ 1 Changed 6 years ago by scratcher

This is plugins directory structure:

 Volume in drive C is System
 Volume Serial Number is FC5F-E6C4

 Directory of C:\Trac\plugins

19.08.2008  13:18    <DIR>          .
19.08.2008  13:18    <DIR>          ..
01.02.2008  15:59             2 125 autonav.py
29.04.2008  11:16             2 255 autonav.pyc
01.02.2008  17:23             1 375 BackLinks.py
29.04.2008  11:16             1 530 BackLinks.pyc
31.07.2008  17:54               799 check_corr_version.py
31.07.2008  17:54             1 270 check_corr_version.pyc
01.02.2008  14:29               617 Color.py
29.04.2008  11:16             1 091 Color.pyc
26.05.2008  10:04                26 ddts-refs.egg-link
19.05.2008  09:22                23 fieldjuggler.egg-link
10.12.2007  19:52            16 347 graphviz-0.6.9-py2.5.egg
06.08.2008  13:06             5 947 PageToDoc-0.1.5-py2.5.egg
19.08.2008  12:17            53 661 PageToDocbook-0.6.2-py2.5.egg
01.02.2008  14:21             2 994 ParentLinkage.py
29.04.2008  11:16             2 931 ParentLinkage.pyc
14.05.2008  16:20             2 044 priority_field.pyc
14.05.2008  16:19             1 802 priority_field.py_
19.05.2008  13:29             1 715 sample1.py
19.05.2008  13:29             2 674 sample1.pyc
07.05.2008  10:16             4 878 TracAcronyms-0.1-py2.5.egg
06.05.2008  17:50            21 637 TracDateField-1.0.1-py2.5.egg
28.05.2008  13:17            41 990 TracMasterTickets-2.1.1-py2.5.egg
12.05.2008  18:19            10 409 TracWikiRename-2.1-py2.5.egg
21.01.2008  14:38            28 556 TracXMLRPC-0.1-py2.5.egg
04.06.2008  09:02            30 710 TracXMLRPC-1.0.0-py2.5.egg
04.02.2008  20:17             8 323 WantedPages-0.3-py2.5.egg
              27 File(s)        247 729 bytes
               2 Dir(s)   1 521 033 216 bytes free

comment:4 follow-up: Changed 6 years ago by anonymous

There is no directories (should they be there?)

Yep, they should. Directory structure should be the same as in the subversion repository:
http://trac-hacks.org/browser/page2docbookplugin/page2docbook/pagetodocbook

Have you built the egg file yourself or have you downloaded the one in the plugin's wiki page?

comment:5 Changed 6 years ago by scratcher

I've tried both: first I've downloaded ready egg from trac-hacks, then I've downloaded zipped source and create egg by myself. Moreover - I've tried this plugin on two different installation of Trac (0.11rc1 and 0.11) - result is the same. Any ideas?

If I understood you correct - it is enough to upload egg via administration panel and it's content must be extracted automatically to plugins directory by Trac?

comment:6 in reply to: ↑ 4 Changed 6 years ago by scratcher

After discovering some output from Tracd console:

127.0.0.1 - - [19/Aug/2008 14:06:41] "GET /Trac/wiki/WikiStart?format=docbook HT
TP/1.1" 500 -
compilation error: element import
xsl:import : invalid URI reference C:\Documents and Settings\pb3b0255\Applicatio
n Data\Python-Eggs\pagetodocbook-0.6.2-py2.5.egg-tmp\pagetodocbook\data\headings
Normalizer\headingsNormalizer.xsl
127.0.0.1 - - [19/Aug/2008 14:07:15] "GET /Trac/wiki/WikiStart?format=docbook HT
TP/1.1" 500 -

I've realized that they were extracted to temporary directory in Application Data\Python-Eggs:

 Volume in drive C is System
 Volume Serial Number is FC5F-E6C4

 Directory of C:\Documents and Settings\pb3b0255\Application Data\Python-
Eggs\pagetodocbook-0.6.2-py2.5.egg-tmp\pagetodocbook\data\html2db

19.08.2008  14:10    <DIR>          .
19.08.2008  14:10    <DIR>          ..
31.07.2007  15:25             3 256 ar01s02.html
31.07.2007  15:25             1 987 ar01s03.html
31.07.2007  15:25             1 763 ar01s04.html
31.07.2007  15:25             1 993 ar01s05.html
31.07.2007  15:25             2 555 ar01s06.html
31.07.2007  15:25            13 393 ar01s07.html
31.07.2007  15:25             5 904 ar01s08.html
31.07.2007  15:25             7 184 ar01s09.html
31.07.2007  15:25             7 836 ar01s10.html
31.07.2007  15:25             5 506 build.xml
31.07.2007  15:25             1 142 example.xsl
31.07.2007  15:25               476 extract-section.xsl
31.07.2007  15:25             1 161 extract-toc.xsl
31.07.2007  15:25             2 396 html2db-utils.xsl
31.07.2007  15:25            18 151 html2db.xsl
31.07.2007  15:25             5 695 index.html
31.07.2007  15:25            25 586 index.src.html
31.07.2007  15:25            30 394 index.xml
31.07.2007  15:25             6 111 LICENSE.txt
31.07.2007  15:25                51 tidy.properties
              21 File(s)        142 540 bytes
               2 Dir(s)   1 519 210 496 bytes free

May be this is Windows-specific behaviour of Python/Trac as I never saw content extracted from egg in plugins folder before? I've tested a lot of plugins before, some of them deployed additional files to Trac, but all of them were extracted to Application Data\Python-Eggs folder in Windows.

comment:7 follow-up: Changed 6 years ago by FilipeCorreia

May be this is Windows-specific behaviour of Python/Trac as I never saw content extracted from egg in plugins folder before? I've tested a lot of plugins before, some of them deployed additional files to Trac, but all of them were extracted to Application Data\Python-Eggs folder in Windows.

Your're right, that's the expected behaviour, on both windows and other platforms.

That error message you got from tracd is an interesting one. Maybe this has to do with differences between windows and *nix paths.
Could you please confirm "headingsNormalizer.xsl" in fact exists in this location on your machine:

C:\Documents and Settings\pb3b0255\Application Data\Python-Eggs\pagetodocbook-0.6.2-py2.5.egg-tmp\pagetodocbook\data\headingsNormalizer\headingsNormalizer.xsl

If it does, then this has to do with what is considered an URI by xsltproc; i think it is not considering windows slashes as a valid URI element.

I'm on vacation, so haven't got the appropriate environment near me to test this but, if you can, i'd suggest you try to apply the following changes in pagetodocbook.py:

On line 42, replace:

<xsl:import href=\"""" + resource_filename(__name__, 'data/html2db/html2db.xsl') + """\" />

by:

<xsl:import href=\"""" + resource_filename(__name__, 'data/html2db/html2db.xsl').replace('\\', '/') + """\" />

On line 52, replace:

<xsl:import href=\"""" + resource_filename(__name__, 'data/headingsNormalizer/headingsNormalizer.xsl') + """\" />

by:

<xsl:import href=\"""" + resource_filename(__name__, 'data/headingsNormalizer/headingsNormalizer.xsl').replace('\\', '/') + """\" />

comment:8 in reply to: ↑ 7 Changed 6 years ago by scratcher

Could you please confirm "headingsNormalizer.xsl" in fact exists in this location on your machine:

C:\Documents and Settings\pb3b0255\Application Data\Python-Eggs\pagetodocbook-0.6.2-py2.5.egg-tmp\pagetodocbook\data\headingsNormalizer\headingsNormalizer.xsl

Yes, it is.

After applied changes path in error messages was changed (backslash to slash), but error remains the same.

Serving on 0.0.0.0:8000 view at http://127.0.0.1:8000/
compilation error: element import
xsl:import : invalid URI reference C:/Documents and Settings/pb3b0255/Applicatio
n Data/Python-Eggs/pagetodocbook-0.6.2-py2.5.egg-tmp/pagetodocbook/data/headings
Normalizer/headingsNormalizer.xsl
127.0.0.1 - - [19/Aug/2008 15:26:39] "GET /Trac/wiki/WikiStart?format=docbook HT
TP/1.1" 500 -

Could it be that the reason is the space in path? In Windows usually you have to enclose path with spaces in it with double quotas.

comment:9 follow-up: Changed 6 years ago by FilipeCorreia

I don't think it has to do with spaces, as they are valid in URIs.

Let's do one more try, please make these the lines 42 and 52 respectively (on pagetodocbook.py):

<xsl:import href=\"file:///""" + resource_filename(__name__, 'data/html2db/html2db.xsl').replace('\\', '/') + """\" />
<xsl:import href=\"file:///""" + resource_filename(__name__, 'data/headingsNormalizer/headingsNormalizer.xsl').replace('\\', '/') + """\" />

comment:10 in reply to: ↑ 9 Changed 6 years ago by scratcher

I don't think it has to do with spaces, as they are valid in URIs.

Let's do one more try, please make these the lines 42 and 52 respectively (on pagetodocbook.py):

127.0.0.1 - - [19/Aug/2008 15:50:43] "GET /Trac HTTP/1.1" 200 -
compilation error: element import
xsl:import : invalid URI reference file:///C:/Documents and Settings/pb3b0255/Ap
plication Data/Python-Eggs/pagetodocbook-0.6.2-py2.5.egg-tmp/pagetodocbook/data/
headingsNormalizer/headingsNormalizer.xsl
127.0.0.1 - - [19/Aug/2008 15:50:48] "GET /Trac/wiki/WikiStart?format=docbook HT
TP/1.1" 500 -

comment:11 Changed 6 years ago by scratcher

I've replaced space character with '%20' in URI and then it works.
Thanks for your help!

So the line now looks like:

<xsl:import href=\"file:///""" + resource_filename(__name__, 'data/html2db/html2db.xsl').replace('\\', '/').replace(' ','%20') + """\" />
<xsl:import href=\"file:///""" + resource_filename(__name__, 'data/headingsNormalizer/headingsNormalizer.xsl').replace('\\', '/').replace(' ','%20') + """\" />

Changed 6 years ago by scratcher

fixed version for Windows environment

comment:12 follow-up: Changed 6 years ago by FilipeCorreia

Glad it's working!

I'll release a new version with this issue fixed around September.

Instead of replacing spaces with '%20' i think the pathname2url() function in urllib will turn out to be a cleaner solution, but still have to confirm if it works as i think it does.

comment:13 in reply to: ↑ 12 Changed 6 years ago by scratcher

I'll release a new version with this issue fixed around September.


Okay, thanks! Just let me know by updating this ticket - I'll check the new version on Windows.

comment:14 Changed 5 years ago by FilipeCorreia

  • Resolution set to fixed
  • Status changed from new to closed

Finally fixed this issue in version control. An egg will hopefully be released on the following weeks.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.