#6579 closed defect (invalid)
Endless loop on missing Request.callbacks attribute
Reported by: | Owned by: | Jonas Borgström | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | general | Version: | devel |
Severity: | normal | Keywords: | |
Cc: | tomek@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Trac uses the following code to resolve missing attribute:
def __getattr__(self, name): """Performs lazy attribute lookup by delegating to the functions in the callbacks dictionary.""" if name in self.callbacks: value = self.callbacks[name](self) setattr(self, name, value) return value raise AttributeError(name)
The problem is, that if the self.callbacks
itself is missing, it ends with endless loop like:
Traceback (most recent call last): File "/var/trac/trac/trac/web/api.py", line 339, in send_error 'text/html') File "/var/trac/trac/trac/web/chrome.py", line 652, in render_template data = self.populate_data(req, data) File "/var/trac/trac/trac/web/chrome.py", line 560, in populate_data d['chrome'].update(req.chrome) File "/var/trac/trac/trac/web/api.py", line 167, in __getattr__ if name in self.callbacks: File "/var/trac/trac/trac/web/api.py", line 167, in __getattr__ if name in self.callbacks: File "/var/trac/trac/trac/web/api.py", line 167, in __getattr__ if name in self.callbacks: File "/var/trac/trac/trac/web/api.py", line 167, in __getattr__ if name in self.callbacks: [...]
We need to check for this condition, like:
-
trac/trac/web/api.py
164 164 def __getattr__(self, name): 165 165 """Performs lazy attribute lookup by delegating to the functions in the 166 166 callbacks dictionary.""" 167 if name in self.callbacks:167 if name != 'callbacks' and name in self.callbacks: 168 168 value = self.callbacks[name](self) 169 169 setattr(self, name, value) 170 170 return value
Attachments (0)
Change History (5)
comment:1 by , 17 years ago
Version: | → devel |
---|
comment:2 by , 17 years ago
Cc: | added |
---|
comment:3 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Ah. In that case you need to file a ticket with the plugin over at Trac-Hacks. It is not really a Trac issue, and it will have to be the responsibility of that plugin to make sure everything works as it should.
Closing as invalid.
comment:4 by , 17 years ago
The term "giant flaming hack" doesn't even begin to describe the code in question. However you can try to isolate the problem by looking for the line "Using patched init" in your log. TracForge is monkey-patching chunks of the 0.11 codebase into 0.10, hilarity ensues.
comment:5 by , 17 years ago
I do agree that this is a Trac Forge issue.
But with a change mentioned, I got a meaningfull error message, that allowed me to find the real cause. Without it, I got the loop and needed to fight the loop problem first. That's why I suggested the change. It could help in any situation, that we have a broken Request object.
Reffering to attribute in attribute-handler without the sanity check if we're reffering to ourself is a bug in my opinion.
As the
self.callbacks
dict is created insideRequest.__init__()
, I can't quite see a situation where it would be missing? And, if it actually is missing somewhere due to perhaps sub-classing that does not call back the main init, that might well be worth looking into.Could you provide some way to reproduce the error you get?