Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#6579 closed defect (invalid)

Endless loop on missing Request.callbacks attribute

Reported by: tomek@… 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

     
    164164    def __getattr__(self, name):
    165165        """Performs lazy attribute lookup by delegating to the functions in the
    166166        callbacks dictionary."""
    167         if name in self.callbacks:
     167        if name != 'callbacks' and name in self.callbacks:
    168168            value = self.callbacks[name](self)
    169169            setattr(self, name, value)
    170170            return value

Attachments (0)

Change History (5)

comment:1 by osimons, 17 years ago

Version: devel

As the self.callbacks dict is created inside Request.__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?

comment:2 by tomek@…, 17 years ago

Cc: tomek@… added

The error is related to TracForge plugin that replaces the Request.init().

The problem I got is indeed TracForge error, but occurs inside Trac itself.

comment:3 by osimons, 17 years ago

Resolution: invalid
Status: newclosed

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 Noah Kantrowitz, 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 tomek@…, 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.

Modify Ticket

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