Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#12679 closed defect (fixed)

TypeError: add_script_data() got an unexpected keyword argument 'dynvars'

Reported by: Gerd Owned by: Jun Omae
Priority: normal Component: DynamicVariablesPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

I installed the plugin on a TRAC 0.12.3 server.

I tried the example report:

SELECT p.value AS __color__, t.id AS ticket, summary, component, severity, reporter
FROM ticket t
  LEFT OUTER JOIN milestone m ON t.milestone = m.name
  LEFT JOIN enum p ON p.name = t.severity AND p.type = 'severity'
  LEFT OUTER JOIN ticket_custom q ON q.ticket = t.id AND q.name = 'queue'
WHERE q.value = '$QUEUE'
  AND milestone = '$MILESTONE'
ORDER BY m.due ASC, p.value

but got the following error:

Warning:
The following arguments are missing: QUEUE
The following arguments are missing: QUEUE, MILESTONE

Trac detected an internal error:
TypeError: add_script_data() got an unexpected keyword argument 'dynvars'
Python Traceback

Most recent call last:
File "C:/Python27/lib/site-packages/trac/web/main.py", line 522, in _dispatch_request
  dispatcher.dispatch(req)
File "C:/Python27/lib/site-packages/trac/web/main.py", line 254, in dispatch
  self._post_process_request(req, *resp)
File "C:/Python27/lib/site-packages/trac/web/main.py", line 363, in _post_process_request
  resp = f.post_process_request(req, *resp)
File "build/bdist.win32/egg/dynvars/web_ui.py", line 44, in post_process_request
  add_script_data(req, dynvars=dynvars)

System Information:

Trac	0.12.3
Babel	0.9.5
Genshi	0.6
pysqlite	2.6.0
Python	2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]
setuptools	0.6c11
SQLite	3.6.21

not sure what caused this, maybe any connection to Changeset 14917? ('Use add_script_data to pass data to the script.')

Attachments (1)

Trac_milestone_dropdown.PNG (3.3 KB) - added by Gerd 9 years ago.
Screenshot empty Milestone drop down

Download all attachments as: .zip

Change History (13)

comment:1 Changed 9 years ago by Gerd

I get the same error when trying this report:

SELECT *
  FROM ticket as t
  WHERE (t.status <> 'closed') and (t.status not in ($STATUS) )

comment:2 Changed 9 years ago by Jun Omae

The add_script_data since Trac 1.0 accepts keyword arguments. The following patch would probably make compatible between 0.12 and 1.0.

  • dynamicvariablesplugin/0.12/dynvars/web_ui.py

    diff --git a/dynamicvariablesplugin/0.12/dynvars/web_ui.py b/dynamicvariablesplugin/0.12/dynvars/web_ui.py
    index 1f69ba2..146ff3a 100644
    a b class DynamicVariablesModule(Component): 
    4141            report = self._get_report(req, check_referer=True)
    4242            for var in self._extract_vars(report):
    4343                dynvars[var] = self._get_options(var.lower())
    44             add_script_data(req, dynvars=dynvars)
     44            add_script_data(req, {'dynvars': dynvars})
    4545        return template, data, content_type
    4646
    4747    # Private methods

Changed 9 years ago by Gerd

Attachment: Trac_milestone_dropdown.PNG added

Screenshot empty Milestone drop down

comment:3 Changed 9 years ago by Gerd

I used the supplied patch: error message is gone now :) Thank you!

But I still don't get the Milestone dropdown list (see screenshot). Is it an issue of my 0.12 trac server? Maybe I should use an older version of the plugin ?

comment:4 in reply to:  3 ; Changed 9 years ago by Ryan J Ollos

Owner: changed from Rob Guttman to Ryan J Ollos
Status: newaccepted

Replying to gerd_h:

I used the supplied patch: error message is gone now :) Thank you!

I'll apply the patch.

But I still don't get the Milestone dropdown list (see screenshot). Is it an issue of my 0.12 trac server? Maybe I should use an older version of the plugin ?

I haven't done any testing with Trac 0.12. You could try the 0.12 branch, or just upgrade your Trac instance. Trac 1.0 was released in 2012.

comment:5 Changed 9 years ago by Ryan J Ollos

In 15357:

0.2.0dev: Make add_script_data usage compatible with Trac 0.12

Refs #12679.

comment:6 in reply to:  4 Changed 9 years ago by Ryan J Ollos

Replying to rjollos:

I haven't done any testing with Trac 0.12. You could try the 0.12 branch, or just upgrade your Trac instance. Trac 1.0 was released in 2012.

Sorry, I was confusing this with DynamicFieldsPlugin which has forked from 0.12 to the trunk. I see that mainline development is still occurring in the 0.12 branch for DynamicVariablesPlugin.

Could you post the SQL for a report in which you find the milestone dropdown to be empty? I'll try to reproduce.

comment:7 Changed 9 years ago by Gerd

This is the given example from the plug-in's homepage, slightly adapted as I have no 'queue' entries in ticket_custom:

SELECT p.value AS __color__, t.id AS ticket, summary, component, severity, reporter
FROM ticket t
  LEFT OUTER JOIN milestone m ON t.milestone = m.name
  LEFT JOIN enum p ON p.name = t.severity AND p.type = 'severity'
  LEFT OUTER JOIN ticket_custom q ON q.ticket = t.id AND q.name = 'queue'
WHERE 
  milestone = '$MILESTONE'
ORDER BY m.due ASC, p.value

comment:8 Changed 9 years ago by Gerd

Another issue, maybe related:

SELECT *
  FROM ticket as t
  WHERE (t.status <> 'closed') and (t.status not in ($STATUS1) )

The relevant parts of my trac.ini look like:

[components]
dynvars.web_ui.dynamicvariablesmodule = enabled

[dynvars]
status1.options = documenting

I expected to have a drop-down list for status1, but I only get an empty edit box (default trac behaviour without plugin)

comment:9 in reply to:  3 ; Changed 9 years ago by Jun Omae

But I still don't get the Milestone dropdown list (see screenshot). Is it an issue of my 0.12 trac server? Maybe I should use an older version of the plugin ?

I guess the same issue exists with Trac 1.0. Could you pleaes try the following patch? I verified with Trac 0.12.x.

  • dynamicvariablesplugin/0.12/dynvars/htdocs/dynamic_variables.js

    diff --git a/dynamicvariablesplugin/0.12/dynvars/htdocs/dynamic_variables.js b/dynamicvariablesplugin/0.12/dynvars/htdocs/dynamic_va
    index 980d148..054e2ca 100644
    a b jQuery(document).ready(function($) { 
    77      var $input = $('input[name="' + field + '"]', $filters);
    88      if ($input.length != 0) {
    99          var $select = $('<select>').insertAfter($input);
    10           $(options).each(function() {
    11             $select.append($('<option>').attr('value', this).text(this));
     10          $.each(options, function(key, val) {
     11            $select.append($('<option />').attr('value', val).text(val));
    1212          });
    1313          $input.hide();
    1414          $select.val($input.val()).change(function() {

comment:10 in reply to:  9 Changed 9 years ago by Gerd

Replying to jun66j5:

I guess the same issue exists with Trac 1.0. Could you pleaes try the following patch? I verified with Trac 0.12.x.

Will do, but currently I am swamped with something else :(
I hope I can test the patch next week ...

comment:11 Changed 9 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

In 15377:

0.2.0dev: Fix empty select with Trac 0.12

Patch by Jun Omae.

Fixes #12679.

comment:12 Changed 9 years ago by Ryan J Ollos

Owner: changed from Ryan J Ollos to Jun Omae

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
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.