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 9DCEE9F7C for ; Wed, 4 Apr 2012 16:54:26 +0000 (UTC) Received: (qmail 95869 invoked by uid 500); 4 Apr 2012 16:54:26 -0000 Delivered-To: apmail-incubator-bloodhound-dev-archive@incubator.apache.org Received: (qmail 95852 invoked by uid 500); 4 Apr 2012 16:54:26 -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 95844 invoked by uid 99); 4 Apr 2012 16:54:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2012 16:54:26 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of gary.martin@wandisco.com designates 74.125.83.47 as permitted sender) Received: from [74.125.83.47] (HELO mail-ee0-f47.google.com) (74.125.83.47) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2012 16:54:21 +0000 Received: by eekc1 with SMTP id c1so182167eek.6 for ; Wed, 04 Apr 2012 09:53:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=WJCPdhbQ11CCGROQQkY5rxMGDzilrPnyizNtPajk1Q8=; b=olsQxJfYNn8jfPy3uHtZywWVxWKHjPBNzg8fCe+l6Ur5bRMuzK1KDhGl04Z6AILxpg xoQ9G+hsMru3Cs9pCTkuogVo0hwWcHVanRGNchnCqPJ3nd7EWTk+UiTmtTMTmvvy2S7p LYyY6EZae+DUhkXiiiSwu+I17Ibl9fsfLYfmth8f2OZCT/7fHDewHepxNuTUjZ78yQnb 4jmq2F44VgJgfYwLKNpsEzfG1O7XIyiMuhOUX7UTvo1Dah1VG/cd8s8EBgJ8s2f0i+EL vstcIgRgvEY5wiH5A2JrjRFHx3GY7eavsj/aNXWiRMOJZWsZd65pROPhsJdjMcH2N3e2 QDOw== Received: by 10.213.4.205 with SMTP id 13mr1603432ebs.89.1333558439688; Wed, 04 Apr 2012 09:53:59 -0700 (PDT) Received: from [10.2.5.127] ([77.86.30.139]) by mx.google.com with ESMTPS id n56sm4096628eeb.4.2012.04.04.09.53.58 (version=SSLv3 cipher=OTHER); Wed, 04 Apr 2012 09:53:59 -0700 (PDT) Message-ID: <4F7C7CA2.5020907@wandisco.com> Date: Wed, 04 Apr 2012 17:53:54 +0100 From: Gary User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120310 Thunderbird/11.0 MIME-Version: 1.0 To: bloodhound-dev@incubator.apache.org Subject: Re: [Apache Bloodhound] #22: Infinite recursion error when initialising a plugin that extends itself References: <052.4da5099d4a3aefbb8748f007a5dcd0fc@incubator.apache.org> <067.375d46ae7cfafe0033257c91c1f333a3@incubator.apache.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQmR0sUF5GyJOCYh3UwiOSrud1lx6hBGk1P3/qXBWOsMuIZ1pfItynrPMz08N7wcw19vGsYC X-Virus-Checked: Checked by ClamAV on apache.org On 04/04/2012 05:43 PM, Ethan Jucovy wrote: >> [ >> 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 > Ah, thanks for pointing that out. I was about to write a ticket to get someone to get the theme engine to change the implementation. I don't particularly mind that a plugin wants to do a lot in their __init__ as long as they are prepared to deal with the potential error. As I think I already say, the only fault I see in Trac on this issue is that it doesn't deal with it quite helpfully enough. Basically I think it should survive the event to the extent of allowing the admin to disable the offending plugin from the admin interface. Cheers, Gary