launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #03910
Re: warning: we will soon have much noise in the test results...
On Monday 26 July 2010 11:55:00 Jonathan Lange wrote:
> On Mon, Jul 26, 2010 at 11:46 AM, Julian Edwards
> <julian.edwards@xxxxxxxxxxxxx> wrote:
> ...
>
> > I've seen a proliferation recently of people writing code like:
> >
> > class FlangeGrobbler:
> > @classmethod
> > def new(cls, ...)
> >
> > which completely bypasses the security adapter when returning new
> > objects.
>
> It depends on how you do it.
>
> You can declare a class as providing an interface and then register
> the class as secured utility for that interface. Grep for
> classProvides in the code to see examples.
>
> The problem isn't how you write the class, it's how you invoke new().
> You can still write new() as a classmethod and invoke it with
> getUtility(IFooSet).new().
I guess I'm struggling to see how @classmethod is useful then. In fact, it's
dangerous.
FWIW I don't think this way of doing things is any better (nor worse, though)
than a utility class, is there a reason to avoid those?
Follow ups
References