# Ticket #10798 (closed defect: fixed)

Opened 4 months ago

## simplemultiproject plugin crashes

Reported by: Assigned to: vitali.sokhin@gmail.com falkb normal SimpleMultiProjectPlugin critical 0.12

### Description

Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/trac/web/api.py", line 436, in send_error
data, 'text/html')
File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 808, in render_template
File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 768, in load_template
File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 482, in get_all_templates_dirs
dirs.extend(provider.get_templates_dirs() or [])
File "build/bdist.linux-x86_64/egg/simplemultiproject/admin.py", line 133, in get_templates_dirs
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 16, in ?
import sys, os, zipimport, time, re, imp, new
File "/usr/lib64/python2.4/os.py", line 133, in ?
from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep,
ImportError: No module named path


## Change History

### (follow-up: ↓ 2 ) 01/16/13 13:27:33 changed by falkb

• owner changed from crossroad to falkb.
• status changed from new to assigned.

The error happens deep down in a standard library function. I searched through the internet and have found #1536 where they found out the error happens if pydoc is not installed, which is a common requiry.

Vitali, please, could you try to install it, and then report back?

### (in reply to: ↑ 1 ) 01/16/13 14:47:30 changed by anonymous

The error happens deep down in a standard library function. I searched through the internet and have found #1536 where they found out the error happens if pydoc is not installed, which is a common requiry. Vitali, please, could you try to install it, and then report back?

I installed epydoc.noarch 0:2.1-3.el5.rf, but it did not help. I get the same error when I enable admin panel Is there a way to add projects withou admin panel?

### 01/16/13 14:56:18 changed by falkb

Well, the according code in SimpleMultiProjectPlugin is:

    def get_templates_dirs(self):
from pkg_resources import resource_filename
return [resource_filename(__name__, 'templates')]


You could try to hack it to something like

    def get_templates_dirs(self):
return ['path_to_templates/templates']


or something like that. This way you avoid accessing the incompatible base library.

### (follow-up: ↓ 5 ) 01/16/13 15:09:45 changed by falkb

Vitali, this page says our problem function resource_filename() is located in setuptools . Have you properly installed that one?

### (in reply to: ↑ 4 ) 01/17/13 08:28:29 changed by anonymous

Vitali, this page says our problem function resource_filename() is located in setuptools . Have you properly installed that one?

I re-installed setuptools and also upgraded trac to 0.12.5, but the problem is the same

Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/Trac-0.12.5-py2.4.egg/trac/web/api.py", line 458, in send_error
File "/usr/lib/python2.4/site-packages/Trac-0.12.5-py2.4.egg/trac/web/chrome.py", line 836, in render_template
File "/usr/lib/python2.4/site-packages/Trac-0.12.5-py2.4.egg/trac/web/chrome.py", line 796, in load_template
File "/usr/lib/python2.4/site-packages/Trac-0.12.5-py2.4.egg/trac/web/chrome.py", line 511, in get_all_templates_dirs
File "build/bdist.linux-x86_64/egg/simplemultiproject/admin.py", line 133, in get_templates_dirs
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 16, in ?
import sys, os, zipimport, time, re, imp, new
File "/usr/lib64/python2.4/os.py", line 133, in ?
from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep,
ImportError: No module named path


I'll try to hack get_templates_dirs

### (follow-up: ↓ 7 ) 01/17/13 08:32:27 changed by falkb

I must confess I never tried it with Python 2.4. Once I used Trac 0.12 I had Python 2.5, now I've got Trac 1.0 with Python 2.7 here.

### (in reply to: ↑ 6 ; follow-up: ↓ 8 ) 01/17/13 08:44:43 changed by vitali

I must confess I never tried it with Python 2.4. Once I used Trac 0.12 I had Python 2.5, now I've got Trac 1.0 with Python 2.7 here.

I need to run trac on RHEL5 and it comes with Pyrthon 2.4. I had run Trac 0.12 without any issue on Python 2.4 until I got the one described above

### (in reply to: ↑ 7 ; follow-up: ↓ 9 ) 01/17/13 09:58:03 changed by falkb

I need to run trac on RHEL5 and it comes with Pyrthon 2.4. I had run Trac 0.12 without any issue on Python 2.4 until I got the one described above

Python 2.4 is very old. I recommend at least 2.5 to you, look here how people had problems with setuptools and 2.4. In this link you can also see they use try-expect but I suspect it wouldn't help us to implement

    def get_templates_dirs(self):
try:
from pkg_resources import resource_filename
return [resource_filename(__name__, 'templates')]
except ImportError:
return []


because then the calling code missed the path as described here in the Trac API docs.

### (in reply to: ↑ 8 ; follow-up: ↓ 10 ) 01/17/13 10:33:10 changed by vitali

I need to run trac on RHEL5 and it comes with Pyrthon 2.4. I had run Trac 0.12 without any issue on Python 2.4 until I got the one described above

Python 2.4 is very old. I recommend at least 2.5 to you, look here how people had problems with setuptools and 2.4. In this link you can also see they use try-expect but I suspect it wouldn't help us to implement {{{ def get_templates_dirs(self): try: from pkg_resources import resource_filename return [resource_filename(name, 'templates')] except ImportError?: return [] }}} because then the calling code missed the path as described here in the Trac API docs.

Thank you very much for your quick and valuable responces.

I know that Python 2.4 is very old, and I'd gladly upgrade, but, unfortunately, it is not under my control.

Meanwhile, I replaced get_templates_dirs with a hard-coded path as you suggested:

def get_templates_dirs(self):
return ['path_to_templates/templates']


Everything works fine, except Milestones, which does not have the Project field:

### (in reply to: ↑ 9 ; follow-ups: ↓ 11 ↓ 12 ) 01/17/13 10:54:55 changed by falkb

Everything works fine, except Milestones, which does not have the Project field:

As explained on wiki:SimpleMultiProjectPlugin#Example (Look for "Associate a milestone in a project"), you must use the Roadmap page to attach milestones to projects. Currently, there appropriate code for extending the pages in the Admin panel.

### (in reply to: ↑ 10 ) 01/17/13 10:56:36 changed by falkb

Currently, there appropriate code ...

Typo. Should be "Currently, there aint no appropriate code ..."

### (in reply to: ↑ 10 ; follow-up: ↓ 13 ) 01/17/13 11:23:09 changed by anonymous

As explained on wiki:SimpleMultiProjectPlugin#Example (Look for "Associate a milestone in a project"), you must use the Roadmap page to attach milestones to projects. Currently, there appropriate code for extending the pages in the Admin panel.

Everyhing works

Thank you very much for your help!!!

### (in reply to: ↑ 12 ) 01/17/13 11:26:25 changed by falkb

Thank you very much for your help!!!

You're welcome. The problem still exists, that's why I think I keep this ticket open. Meanwhile I asked on the Trac development mailing-list

### (follow-up: ↓ 15 ) 01/17/13 14:17:39 changed by jun66j5

Reproduced. I checked log/trac.log and consider that simplemultiproject/version.py has two problems.

1. Syntax error at ... if ... else ... with Python 2.4
2. Import Error at import user_time with Trac 0.12.x

The following patch would be simple to remove using user_time.

Index: simplemultiproject/version.py
===================================================================
--- simplemultiproject/version.py       (revision 12533)
+++ simplemultiproject/version.py       (working copy)
@@ -7,7 +7,6 @@
from simplemultiproject.model import *

#trac
-from trac import __version__ as VERSION
from trac.attachment import AttachmentModule
from trac.config import ExtensionOption
from trac.core import *
@@ -23,9 +22,6 @@
get_datetime_format_hint, format_date, \
format_datetime, from_utimestamp

-if VERSION > '0.12':
-    from trac.util.datefmt import user_time
-
from trac.web.api import IRequestHandler, IRequestFilter, ITemplateStreamFilter
@@ -229,10 +225,11 @@

if 'time' in req.args:
time = req.args.get('time', '')
-            if VERSION <= '0.12':
-                version.time = time and parse_date(time, req.tz, 'datetime') or None
+            if time:
+                version.time = parse_date(time, tzinfo=req.tz,
+                                          locale=req.locale, hint='datetime')
else:
-                version.time = user_time(req, parse_date, time, hint='datetime') if time else None
+                version.time = None
else:
version.time = None


### (in reply to: ↑ 14 ; follow-up: ↓ 16 ) 01/17/13 14:28:49 changed by falkb

Reproduced. I checked log/trac.log and consider that simplemultiproject/version.py has two problems.

jun66j5, are you sure this is the right ticket? Your patch is for version.py though vitali reported a problem in admin.py. Second, your patch would revert [12453] which was a necessary port to make it work with Trac 1.0. What was the traceback in your case? Nevertheless thanks a lot for your attention to this problem here.

### (in reply to: ↑ 15 ) 01/17/13 14:50:06 changed by jun66j5

jun66j5, are you sure this is the right ticket? Your patch is for version.py though vitali reported a problem in admin.py.

Right. If failed on loading a plugin, import pkg_resouces.resource_filename failed. See attachment:0.12-t10798-trac.log.

Second, your patch would revert [12453] which was a necessary port to make it work with Trac 1.0. What was the traceback in your case?

If you want to work with Trac 0.12, it shouldn't use user_time.

Also, that code

    user_time(req, parse_date, time, hint='datetime')


works as the following with Trac 0.12 compatibility.

    parse_date(time, tzinfo=req.tz, locale=req.locale, hint='datetime')


### 01/17/13 15:09:10 changed by jun66j5

In addition, the check of Trac version is wrong. When Trac is 0.12.1 or later, that code will import user_time.

if VERSION > '0.12':
from trac.util.datefmt import user_time


I think that it should be the following in that case.

try:
from trac.util.datefmt import user_time
except ImportError:
# if not needed, user_time = None
def user_time(req, func, *args, **kwargs):
"""porting from 1.0-stable"""
...


### (follow-ups: ↓ 19 ↓ 20 ) 01/17/13 15:12:09 changed by falkb

Hi jun66j5,

jun66j5, are you sure this is the right ticket? Your patch is for version.py though vitali reported a problem in admin.py.

Right. If failed on loading a plugin, import pkg_resouces.resource_filename failed. See attachment:0.12-t10798-trac.log.

Double-check: Do I understand right, that import error in admin.py is a subsequent error of a syntax error in version.py? And your patch includes the fix for admin.py as well?

If you want to work with Trac 0.12, it shouldn't use user_time.

Does it mean, your patch in 14 works for 0.12 _and_ 1.0?

### (in reply to: ↑ 18 ) 01/17/13 15:31:08 changed by vitali

Double-check: Do I understand right, that import error in admin.py is a subsequent error of a syntax error in version.py? And your patch includes the fix for admin.py as well?

I did not connect it to the fail in admin.py, but I did see an error while compiling version.py

byte-compiling build/bdist.linux-x86_64/egg/simplemultiproject/version.py to version.pyc
File "build/bdist.linux-x86_64/egg/simplemultiproject/version.py", line 235
version.time = user_time(req, parse_date, time, hint='datetime') if time else None
^
SyntaxError: invalid syntax



### (in reply to: ↑ 18 ; follow-up: ↓ 22 ) 01/17/13 15:50:34 changed by jun66j5

Sorry. I've mistaken. New patch is here, t10798-2.diff.

Double-check: Do I understand right, that import error in admin.py is a subsequent error of a syntax error in version.py? And your patch includes the fix for admin.py as well?

Yes. The issue for admin.py is caused by SyntaxError and ImportError in version.py. The patch does NOT include any changes for admin.py, but it's right.

If you want to work with Trac 0.12, it shouldn't use user_time.

Does it mean, your patch in 14 works for 0.12 _and_ 1.0?

I tested with t10798-2.diff on Trac 0.12 and 1.0.

Vitali, could you please try the latest patch?

### (follow-up: ↓ 23 ) 01/17/13 16:18:55 changed by falkb

(In [12535]) Refs #10798: applied patch attachment:ticket:10798:t10798-2.diff of jun66j5 that fixes [12453]. Thanks a lot! Commit [12453] works for Trac 1.0 but led to Import errors in admin.py on Trac 0.12. This patch works for me with Trac 1.0.0

### (in reply to: ↑ 20 ) 01/18/13 16:13:23 changed by vitali

Vitali, could you please try the latest patch?

t10798-2.diff works for me on Trac 0.12-5 with Python 2.4

Thank you very much

### (in reply to: ↑ 21 ; follow-up: ↓ 24 ) 01/18/13 16:31:05 changed by vitali

I also checked out [12535] to test, but when I tried to generate plugin .egg by running python setup.py bdist_egg

I got:

Traceback (most recent call last):
File "setup.py", line 21, in ?
entry_points = {'trac.plugins': ['simplemultiproject = simplemultiproject']}
File "/usr/lib64/python2.4/distutils/core.py", line 149, in setup
dist.run_commands()
File "/usr/lib64/python2.4/distutils/dist.py", line 946, in run_commands
self.run_command(cmd)
File "/usr/lib64/python2.4/distutils/dist.py", line 966, in run_command
cmd_obj.run()
File "/usr/lib/python2.4/site-packages/setuptools/command/bdist_egg.py", line 167, in run
self.run_command("egg_info")
File "/usr/lib64/python2.4/distutils/cmd.py", line 333, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python2.4/distutils/dist.py", line 966, in run_command
cmd_obj.run()
File "/usr/lib/python2.4/site-packages/setuptools/command/egg_info.py", line 171, in run
self.find_sources()
File "/usr/lib/python2.4/site-packages/setuptools/command/egg_info.py", line 252, in find_sources
mm.run()
File "/usr/lib/python2.4/site-packages/setuptools/command/egg_info.py", line 306, in run
File "/usr/lib/python2.4/site-packages/setuptools/command/egg_info.py", line 333, in add_defaults
rcfiles = list(walk_revctrl())
File "/usr/lib/python2.4/site-packages/setuptools/command/sdist.py", line 45, in walk_revctrl
File "/usr/lib/python2.4/site-packages/setuptools/command/sdist.py", line 52, in _default_revctrl
for path in finder(dirname,path):
File "/usr/lib/python2.4/site-packages/setuptools/command/sdist.py", line 98, in entries_finder
log.warn("unrecognized .svn/entries format in %s", dirname)
NameError: global name 'log' is not defined



### (in reply to: ↑ 23 ) 01/18/13 21:35:36 changed by falkb

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

File "/usr/lib/python2.4/site-packages/setuptools/command/sdist.py", line 98, in entries_finder log.warn("unrecognized .svn/entries format in %s", dirname) NameError?: global name 'log' is not defined

Well, this is a known problem with a bad constellation of old versions of setuptool and svn. I've found some workarounds and tricks making it work somehow. I understood it as if setuptool has a little bug that bites you there. Just ask more here, if it doesn't work for you, maybe we can help you then.

Anyway, the actual problem is confirmed to be solved. Thanks a lot jun66j5.

### Add/Change #10798 (simplemultiproject plugin crashes)

Change Properties