Edgewall Software
Modify

Opened 20 years ago

Closed 20 years ago

#846 closed defect (fixed)

Error on Custom Query with python 2.1

Reported by: vittorio Owned by: Christopher Lenz
Priority: high Milestone: 0.8
Component: ticket system Version: devel
Severity: major Keywords: query
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

i get following Oops when clicking on "Custom Query" using python 2.1:

Traceback (most recent call last):
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 526, in cgi_start
    real_cgi_start()
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 521, in real_cgi_start
    dispatch_request(path_info, args, req, env)
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 436, in dispatch_request
    module.run()
  File "/usr/lib/python2.1/site-packages/trac/Module.py", line 44, in run
    self.render()
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 95, in render
    self._render_editor(constraints, order, desc)
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 123, in _render_editor
    constraints, 'query.options.')
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 108, in add_options
    util.add_to_hdf(options, self.req.hdf, prefix + field)
NameError: global name 'self' is not defined

trunk r990, python 2.1.3

Attachments (3)

query_python21.patch (3.1 KB ) - added by Christopher Lenz 20 years ago.
Patch for Python2.1 compat. Please try and report back.
query_python21.2.patch (3.8 KB ) - added by Christopher Lenz 20 years ago.
New patch for python2.1 compat. Includes first patch.
query_python21.3.patch (4.1 KB ) - added by Christopher Lenz 20 years ago.
Updated patch again.

Download all attachments as: .zip

Change History (12)

comment:1 by vittorio, 20 years ago

Component: report systemticket system
Keywords: query added

comment:2 by Christopher Lenz, 20 years ago

Status: newassigned

by Christopher Lenz, 20 years ago

Attachment: query_python21.patch added

Patch for Python2.1 compat. Please try and report back.

comment:3 by vittorio, 20 years ago

after applying query_python21.patch i get following error on custom query:

Traceback (most recent call last):
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 526, in cgi_start
    real_cgi_start()
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 521, in real_cgi_start
    dispatch_request(path_info, args, req, env)
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 436, in dispatch_request
    module.run()
  File "/usr/lib/python2.1/site-packages/trac/Module.py", line 44, in run
    self.render()
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 95, in render
    self._render_editor(constraints, order, desc)
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 131, in _render_editor
    self.req.hdf, 'query.options.')
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 113, in add_db_options
    cursor.execute(sql)
NameError: global name 'cursor' is not defined

by Christopher Lenz, 20 years ago

Attachment: query_python21.2.patch added

New patch for python2.1 compat. Includes first patch.

comment:4 by vittorio, 20 years ago

following problem with query_python21.2.patch:

Traceback (most recent call last):
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 526, in cgi_start
    real_cgi_start()
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 521, in real_cgi_start
    dispatch_request(path_info, args, req, env)
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 436, in dispatch_request
    module.run()
  File "/usr/lib/python2.1/site-packages/trac/Module.py", line 44, in run
    self.render()
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 93, in render
    self._render_editor(constraints, order, desc)
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 129, in _render_editor
    self.req.hdf, 'query.options.')
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 117, in add_db_options
    add_options(field, options, constraints, hdf, prefix)
NameError: global name 'add_options' is not defined

comment:5 by vittorio, 20 years ago

when adding as advised at the begining of Query.py:

from __future__ import nested_scopes

the Custom Query works.

but i get following error when clicking on Refine Query in Roadmap view:

Traceback (most recent call last):
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 526, in cgi_start
    real_cgi_start()
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 521, in real_cgi_start
    dispatch_request(path_info, args, req, env)
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 436, in dispatch_request
    module.run()
  File "/usr/lib/python2.1/site-packages/trac/Module.py", line 44, in run
    self.render()
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 94, in render
    self._render_editor(constraints, order, desc)
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 133, in _render_editor
    self.req.hdf, 'query.options.')
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 118, in add_db_options
    add_options(field, options, constraints, hdf, prefix)
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 105, in add_options
    if check and (option['name'] in constraints[field]):

comment:6 by vittorio, 20 years ago

full traceback:

Traceback (most recent call last):
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 526, in cgi_start
    real_cgi_start()
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 521, in real_cgi_start
    dispatch_request(path_info, args, req, env)
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 436, in dispatch_request
    module.run()
  File "/usr/lib/python2.1/site-packages/trac/Module.py", line 44, in run
    self.render()
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 94, in render
    self._render_editor(constraints, order, desc)
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 133, in _render_editor
    self.req.hdf, 'query.options.')
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 118, in add_db_options
    add_options(field, options, constraints, hdf, prefix)
  File "/usr/lib/python2.1/site-packages/trac/Query.py", line 105, in add_options
    if check and (option['name'] in constraints[field]):
TypeError: 'in ' requires character as left operand

by Christopher Lenz, 20 years ago

Attachment: query_python21.3.patch added

Updated patch again.

comment:7 by Christopher Lenz, 20 years ago

[991] and [992] should have fixed this problem.

comment:8 by vittorio, 20 years ago

[991] and [992] fixed the problem.

comment:9 by Christopher Lenz, 20 years ago

Resolution: fixed
Status: assignedclosed

Confirmed.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christopher Lenz.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christopher Lenz to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.