Edgewall Software

Opened 9 years ago

Last modified 9 years ago

#12062 closed defect

Missing attributes in FakePerm class — at Initial Version

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

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 :

diff --git a/trac/web/main.py b/trac/web/main.py
index f52444f..cc718df 100644
--- a/trac/web/main.py
+++ b/trac/web/main.py
@@ -71,8 +71,11 @@ class FakeSession(dict):
 class FakePerm(dict):
     def require(self, *args):
         return False
+    def has_permission(self, *args):
+        return False
     def __call__(self, *args):
         return self
+    assert_permission = require
 
 
 class RequestWithSession(Request):

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

Change History (0)

Note: See TracTickets for help on using tickets.