Opened 3 years ago

Closed 3 years ago

# Getting TracJsGanttPlugin to work with Trac 1.4

Reported by: Owned by: seligman@… Jun Omae normal TracJsGanttPlugin normal Gantt lukas.arnold@… 1.4

A user has been using Trac 1.0.4. I've tried to set up a separate web server with just Trac under CentOS7, python 2.7.5. I used "pip install Trac" and got Trac 1.4.

The user specifically requested that the TracJsGanttPlugin work. I've been fiddling with the code, and have made the changes indicated below. It's at the point where I don't get error messages when the plugin is enabled... but the plugin doesn't display anything. I tried the example:

[[TracJSGanttChart(sample=1)]]


but I just get a blank line.

Have I missed anything?

The attached files show the code changes I made to trac/env.py, tracjsgantt/tracpm.py, and tracjsgantt/tracjsgantt.py.

### comment:1 Changed 3 years ago by seligman@…

I should add: I know nothing about Trac or its API. I've just tried to get things to compile/interpret based on previous tickets I found on the web.

### comment:2 Changed 3 years ago by anonymous

Oops! Forgot to include the trac log:

2019-12-10 14:13:55,170 Trac[env] INFO: -------------------------------- environment startup [Trac 1.4] --------------------------------
2019-12-10 14:13:55,667 Trac[loader] ERROR: Skipping "datefield.filter = datefield.filter": VersionConflict: (Trac 1.4 (/usr/lib64/python2.7/site-packages), Requirement.parse('Trac<1.2,>=1.0'))
2019-12-10 14:13:56,353 Trac[tracpm] INFO: Initializing TracPM
2019-12-10 14:13:56,546 Trac[register] WARNING: RegistrationModule is disabled because the password store does not support writing.
2019-12-10 14:13:56,547 Trac[web_ui] WARNING: AccountModule is disabled because no configured password store supports writing.
2019-12-10 14:13:56,668 Trac[git_fs] INFO: detected GIT version 1.8.3.1
2019-12-10 14:13:56,980 Trac[chrome] WARNING: Component TotalHoursFilter relies on deprecated Genshi stream filtering
2019-12-10 14:13:57,385 Trac[tracpm] INFO: Found 2 enabled ITaskSorter implementations.  Using <Component tracjsgantt.tracpm.ProjectSorter>.



### comment:3 Changed 3 years ago by Jun Omae

Description: modified (diff)

### comment:4 Changed 3 years ago by Ryan J Ollos

Owner: changed from Chris Nelson to Ryan J Ollos new → accepted

Please see TracDev/SubmittingPatches for future patch submissions: unified diff in a single file is highly preferred.

### comment:5 Changed 3 years ago by seligman@…

I wasn't clear: Those diff outputs are meant to show the work I did, not to be formal submitted patches to the plug-in. For all I know, I broke TracJsGantt instead of making it almost work. The only effect of my changes that I can see is that I no longer get error messages when I try to use it.

### comment:6 Changed 3 years ago by Ryan J Ollos

To show the work you did, a single-file unified diff is preferred.

### comment:7 follow-up:  8 Changed 3 years ago by anonymous

Very well. It's file trac-patches.patch.

### comment:8 in reply to:  7 Changed 3 years ago by Jun Omae

Very well. It's file trac-patches.patch.

Thanks, but the attached patch is not an unified-diff. svn diff or diff -u should be used. Also, the patch includes changes of trac/env.py. Those changes cannot be accepted. The patch must be only changes of TracJsGanttPlugin.

### comment:9 Changed 3 years ago by seligman@…

We've got a major communications breakdown here.

I'm not proposing any changes to anything in Trac. I don't know the Trac API. I don't even use Trac; I've got a user who wants to use it.

I'm asking how to get TracJsGanttPlugin to work under Trac 1.4. My changes just got code to run without an error message.

Let's try a different track: Ignore my diff files. Try running TracJsGantt in Trac 1.4. It will crash. What's the fix?

### comment:10 Changed 3 years ago by Ryan J Ollos

Owner: Ryan J Ollos deleted accepted → new

### comment:11 Changed 3 years ago by Jun Omae

Attached patch, t13713.diff, is to make compatible with Trac 1.2 and 1.4. I confirmed with 1.2 and 1.4, but I have never used the plugin. Could you please try to the patch?

### comment:12 Changed 3 years ago by seligman@…

Thanks, Jun. That fixes the problem with tracpm.py, but there's still a problem with tracjsgantt.py.

Here's the log file:

2019-12-19 09:02:28,311 Trac[env] INFO: -------------------------------- environment startup [Trac 1
.4] --------------------------------
2019-12-19 09:02:28,913 Trac[loader] ERROR: Skipping "datefield.filter = datefield.filter": VersionConflict: (Trac 1.4 (/usr/lib64/python2.7/site-packages), Requirement.parse('Trac<1.2,>=1.0'))
2019-12-19 09:02:30,100 Trac[tracpm] INFO: Initializing TracPM
2019-12-19 09:02:30,329 Trac[register] WARNING: RegistrationModule is disabled because the password
store does not support writing.
2019-12-19 09:02:30,330 Trac[web_ui] WARNING: AccountModule is disabled because no configured password store supports writing.
2019-12-19 09:02:30,521 Trac[git_fs] INFO: detected GIT version 1.8.3.1
2019-12-19 09:02:30,876 Trac[chrome] WARNING: Component TotalHoursFilter relies on deprecated Genshi stream filtering
2019-12-19 09:02:31,272 Trac[tracpm] INFO: Found 2 enabled ITaskSorter implementations.  Using <Component tracjsgantt.tracpm.ProjectSorter>.
2019-12-19 09:02:31,291 Trac[formatter] ERROR: Macro TracJSGanttChart(format=week,order=milestone) failed for <Resource u'wiki:WikiStart'>:
Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/trac/wiki/formatter.py", line 818, in _macro_formatter
return macro.ensure_inline(macro.process(args), in_paragraph)
File "/usr/lib64/python2.7/site-packages/trac/wiki/formatter.py", line 389, in process
text = self.processor(text)
File "/usr/lib64/python2.7/site-packages/trac/wiki/formatter.py", line 361, in _macro_processor
text)
File "/usr/lib/python2.7/site-packages/Trac_jsGantt-0.11-py2.7.egg/tracjsgantt/tracjsgantt.py", line 739, in expand_macro
File "/usr/lib/python2.7/site-packages/Trac_jsGantt-0.11-py2.7.egg/tracjsgantt/tracjsgantt.py", line 501, in _format_ticket
File "/usr/lib/python2.7/site-packages/Trac_jsGantt-0.11-py2.7.egg/tracjsgantt/tracjsgantt.py", line 424, in _task_display
_buildEnumMap(colorBy)
File "/usr/lib/python2.7/site-packages/Trac_jsGantt-0.11-py2.7.egg/tracjsgantt/tracjsgantt.py", line 409, in _buildEnumMap
db = self.env.get_db_cnx()
AttributeError: 'Environment' object has no attribute 'get_db_cnx'


When I look at the code around line 409 in tracjsgantt.py:

	def _buildEnumMap(field):
self.classMap = {}
db = self.env.get_db_cnx()
cursor = db.cursor()
cursor.execute("SELECT name," +
db.cast('value', 'int') +
" FROM enum WHERE type=%s", (field,))
for name, value in cursor:
self.classMap[name] = value


To my uninformed eyes, since I'm not familiar with database calls, it looks like this needs the same kind of database-access update you did in tracpm.py. Would you consider supplying a patch for tracjsgantt.py? Otherwise I'd have to guess what needs to be done based on the lines of code you updated in tracpm.py.

### comment:13 Changed 3 years ago by Jun Omae

It seems that you're still using https://trac-hacks.org/svn/tracjsganttplugin/0.11/. There is new URL for Trac 1.2+. Version of the plugin is 1.2.0.0 (your installed version is 0.11).

#### Installation steps with the patch

1. svn co https://trac-hacks.org/svn/tracjsganttplugin/1.2/
2. Apply t13713.diff
3. python setup.py bdist_egg
4. easy_install -UZ dist/*.egg

### comment:14 follow-up:  15 Changed 3 years ago by seligman@…

The goods news is that with those changes, I no longer get any error messages in the log file. After reloading httpd and refresh the main Trac page, the log file shows:

2019-12-19 12:11:35,292 Trac[env] INFO: -------------------------------- environment startup [Trac 1.4] --------------------------------
2019-12-19 12:11:35,800 Trac[loader] ERROR: Skipping "datefield.filter = datefield.filter": VersionConflict: (Trac 1.4 (/usr/lib64/python2.7/site-packages), Requirement.parse('Trac<1.2,>=1.0'))
2019-12-19 12:11:36,504 Trac[tracpm] INFO: Initializing TracPM
2019-12-19 12:11:36,719 Trac[register] WARNING: RegistrationModule is disabled because the password store does not support writing.
2019-12-19 12:11:36,720 Trac[web_ui] WARNING: AccountModule is disabled because no configured password store supports writing.
2019-12-19 12:11:36,827 Trac[git_fs] INFO: detected GIT version 1.8.3.1
2019-12-19 12:11:37,184 Trac[chrome] WARNING: Component TotalHoursFilter relies on deprecated Genshi stream filtering
2019-12-19 12:11:37,602 Trac[tracpm] INFO: Found 2 enabled ITaskSorter implementations.  Using <Component tracjsgantt.tracpm.ProjectSorter>.


But the wiki page just shows a blank line instead of a Gantt chart. The text within the wiki reads:

[[TracJSGanttChart(format=week,order=milestone)]]

[[TracJSGanttChart(sample=1)]]


From the plugin documentation, even if the user has a problem for the first use of TracJSGanttChart, the second line should show a test display. Instead I just see a blank line.

Any ideas?

### comment:15 in reply to:  14 Changed 3 years ago by Jun Omae

The goods news is that with those changes, I no longer get any error messages in the log file. After reloading httpd and refresh the main Trac page, the log file shows:

Thanks for the feedback. I'll push the patch to 1.2 branch.

But the wiki page just shows a blank line instead of a Gantt chart. The text within the wiki reads:

[[TracJSGanttChart(format=week,order=milestone)]]

[[TracJSGanttChart(sample=1)]]


The issue is a duplicate of #12986, and outside scope of this ticket.

### comment:16 Changed 3 years ago by Jun Omae

Owner: set to Jun Omae → fixed new → closed

In 17638:

Trac-jsGantt 1.2.0.0dev: make compatible with Trac 1.4 (closes #13713)

### comment:17 follow-up:  19 Changed 3 years ago by anonymous

Thanks for the effort, but I'm afraid that is is not a duplicate of issue #12986. In that ticket, the issue that only one chart is displayed when there are multiple charts on the page. In my case, no charts are shown at all. If I edit the wiki page to just include:

[[TracJSGanttChart(sample=1)]]


or edit the page to just have

[[TracJSGanttChart(format=week,order=milestone)]]


In neither case is any kind of chart displayed, just a blank line.

### comment:18 Changed 3 years ago by Jun Omae

No. [[TracJSGanttChart(format=week,order=milestone)]] has same result between 0.11 and 1.2. The macro says No tasks selected on both versions. That is not compatibility issue with Trac 1.4.

The macro has no query parameters. I consider that you have no tickets matched with default query. Any tickets should be created before trying the macro on your new environment.

If you encounter issues of the plugins except compatibility with Trac 1.4, please ask on the mailing list before creating new ticket. Also, I think I cannot solve your problems because I have never used the plugin. If you think encountering compatibility issue with Trac 1.4, please compare results between Trac 1.0.x with trajsgantt 0.11 and Trac 1.4 trajsgantt 1.2 and describe how to reproduce, here.

### comment:19 in reply to:  17 Changed 3 years ago by Jun Omae

If I edit the wiki page to just include:

[[TracJSGanttChart(sample=1)]]


Works fine on my fresh environment.

### Modify Ticket

Change Properties