Edgewall Software
Modify

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#12561 closed defect (fixed)

AttributeError: 'FakeSession' object has no attribute 'as_int'

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.2
Component: general Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fixed regression in r14707 that resulted in AttributeError: 'FakeSession' object has no attribute 'as_int'.

API Changes:
  • Added SessionDict class, which DetachedSession and FakeSession inherit from.
  • Added cookie kw arg to MockRequest object.
Internal Changes:

Description

I noticed while working on #12559 that due to changes in #12446, the following can result when an exception is raised:

Traceback (most recent call last):
  File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/web/api.py", line 710, in send_error
    data, 'text/html')
  File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/web/chrome.py", line 1138, in render_template
    if not req.session.as_int('accesskeys', 0):
AttributeError: 'FakeSession' object has no attribute 'as_int'

For example, raise an exception in get_connection:

  • trac/db/sqlite_backend.py

     
    187187        yield 'sqlite', -1 if self.error else 1
    188188
    189189    def get_connection(self, path, log=None, params={}):
     190        raise Exception()
    190191        self.required = True
    191192        params['extensions'] = self._extensions
    192193        if path == ':memory:':

Attachments (0)

Change History (6)

comment:1 by Ryan J Ollos, 8 years ago

Proposed changes in log:rjollos.git:t12561.1.

comment:2 by Ryan J Ollos, 8 years ago

Release Notes: modified (diff)

I've settled on using SessionDict for the new class: [0d27c082/rjollos.git], however I'll consider any feedback.

comment:3 by Jun Omae, 8 years ago

rjollos.git@t12561.3 and SessionDict look good to me.

comment:4 by Ryan J Ollos, 8 years ago

API Changes: modified (diff)
Resolution: fixed
Status: assignedclosed

Thanks for review. Committed to 1.2-stable in r15075, merged to trunk in r15076.

comment:5 by Ryan J Ollos, 7 years ago

Should we modify the initializer of SessionDict to have the same signature as dict, in order to avoid problems like that in th:r16119?

in reply to:  5 comment:6 by Ryan J Ollos, 7 years ago

Replying to Ryan J Ollos:

Should we modify the initializer of SessionDict to have the same signature as dict, in order to avoid problems like that in th:r16119?

Fixed in r15311, merged to trunk in r15312.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos 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.