Edgewall Software

Opened 9 years ago

Last modified 9 years ago

#12062 closed defect

Missing attributes in FakePerm class — at Version 2

Reported by: anonymous Owned by:
Priority: normal Milestone: 1.0.7
Component: general Version: 1.1.3
Severity: normal Keywords: permission
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Ryan J Ollos)

As I understand it, FakeSession and FakePerm objects are returned when Trac is not able to get the real information from the database.

However, the FakePerm class lacks the has_permission and assert_permission functions, which has lead to traces like this in our logs:

2015-05-06 16:11:16,671 Trac[main] ERROR: can't retrieve session: TimeoutError: Unable to get database connection within 0 seconds.
2015-05-06 16:11:16,673 Trac[chrome] ERROR: Traceback (most recent call last):
  File "/local/engine/trac/trac/web/chrome.py", line 773, in prepare_request
    contributor.get_navigation_items(req) or []:
  File "/local/engine/trac-plugins/xmlrpc-plugin/tracrpc/web_ui.py", line 205, in get_navigation_items
    if req.perm.has_permission('XML_RPC'):
AttributeError: 'FakePerm' object has no attribute 'has_permission'

This also happen in bitten/master.py and bitten/admin.py

The server is Lighttpd running Trac v1.1.3

For the moment, I simply did this :

  • trac/web/main.py

    diff --git a/trac/web/main.py b/trac/web/main.py
    index f52444f..cc718df 100644
    a b class FakeSession(dict):  
    7171class FakePerm(dict):
    7272    def require(self, *args):
    7373        return False
     74    def has_permission(self, *args):
     75        return False
    7476    def __call__(self, *args):
    7577        return self
     78    assert_permission = require
    7679
    7780
    7881class RequestWithSession(Request):

note: the #!diff and #!patch do not seem to work in the above block

Change History (2)

comment:1 by ebouaziz@…, 9 years ago

forgot to put my email as reporter, please cc me

comment:2 by Ryan J Ollos, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.