Return-Path: X-Original-To: apmail-incubator-bloodhound-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-bloodhound-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6B0019B3A for ; Wed, 4 Apr 2012 16:44:35 +0000 (UTC) Received: (qmail 51373 invoked by uid 500); 4 Apr 2012 16:44:35 -0000 Delivered-To: apmail-incubator-bloodhound-dev-archive@incubator.apache.org Received: (qmail 51342 invoked by uid 500); 4 Apr 2012 16:44:35 -0000 Mailing-List: contact bloodhound-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: bloodhound-dev@incubator.apache.org Delivered-To: mailing list bloodhound-dev@incubator.apache.org Received: (qmail 51322 invoked by uid 99); 4 Apr 2012 16:44:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2012 16:44:35 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ethan.jucovy@gmail.com designates 74.125.82.41 as permitted sender) Received: from [74.125.82.41] (HELO mail-wg0-f41.google.com) (74.125.82.41) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2012 16:44:29 +0000 Received: by wgbds1 with SMTP id ds1so622708wgb.0 for ; Wed, 04 Apr 2012 09:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Eni/ylgGuZPMizWDO/TV5aTFJcg30u0mufcXWHdh7p8=; b=dXY2cqDWxSvXZDXmRSCleQ963OoTKoymDvVgbK663Ly/neQg55FW7oiDfvQwA4c4hE MwmgcCwVkYBJLFBCPeqqVzUiaDWlPlkzMFq78kic3HY7Yy9kr81X6Opw500CH9VKz2DR B6Rj40Rj3v55/O1IAMftNplZ0NcQa/mjUC7P0bc8R5BlxnBRmy/JKHEAs86QWGDYb0pa EZZeqffOHJBJLH8GwG8yhqFprE+DL/r000iaMFcGFCRlTx22y4bm7SvvXQCYgungm2Uo UqkefGIXdAfPLDhvbrWmIY60L2gZA4g7hYiOI91RRGxo35p9s4O/nh7ISmYaMa2jkC1K fHCw== Received: by 10.180.92.228 with SMTP id cp4mr6534213wib.2.1333557848949; Wed, 04 Apr 2012 09:44:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.180.104.34 with HTTP; Wed, 4 Apr 2012 09:43:48 -0700 (PDT) In-Reply-To: <067.375d46ae7cfafe0033257c91c1f333a3@incubator.apache.org> References: <052.4da5099d4a3aefbb8748f007a5dcd0fc@incubator.apache.org> <067.375d46ae7cfafe0033257c91c1f333a3@incubator.apache.org> From: Ethan Jucovy Date: Wed, 4 Apr 2012 12:43:48 -0400 Message-ID: Subject: Re: [Apache Bloodhound] #22: Infinite recursion error when initialising a plugin that extends itself To: bloodhound-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=f46d0435c070dfc2a804bcdd21c3 --f46d0435c070dfc2a804bcdd21c3 Content-Type: text/plain; charset=ISO-8859-1 > > [ > http://svn.apache.org/viewvc/incubator/bloodhound/trunk/trac/trac/core.py?view=diff&r1=1309469&r2=1309470&pathrev=1309470 > r1309470] fixes by dynamically replacing the __init__ of components with > one that runs the original __init__ on the condition that it has not > already been run. > > I suspect what would be better in the long run would be to catch the > recursion error and turn it into something that can be reported but allows > Bloodhound to continue working. Plugins should probably keep track of > whether an instance has already been initialised. This issue was raised on trac-dev[1]. It was pointed out that the ThemeEngine plugin is incorrectly accessing its extension points in __init__, which it should not do: "A component constructor is called in a special way, as you've found out, and it should really do pretty much nothing. Example of valid use is to set a list to [], a hash to {}, or such. In trunk you could even use @lazy (http://trac.edgewall.org/changeset/10737) to help with such things. So doing anything lengthy is prohibited and the same for "re-entering" the component machinery." Perhaps Trac core should be throwing a more helpful error than infinite recursion, but the correct fix here is to make ThemeEngineSystem.__init__ do less (e.g. ``self._info = None``) and populate its ``self.info`` dict lazily. There's no need for this __init__-replacing magic in core. [1] http://old.nabble.com/Create-new-ticket-vs-reopen--9418-(if-necessary--)-td33164546.html --f46d0435c070dfc2a804bcdd21c3--