Edgewall Software

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' — at Version 4

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:':

Change History (4)

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.

Note: See TracTickets for help on using tickets.