[packagekit] yum2 backend

Robin Norwood rnorwood at redhat.com
Fri Feb 15 08:17:16 PST 2008


On Fri, 15 Feb 2008 16:26:29 +0100
"Patryk Zawadzki" <patrys at pld-linux.org> wrote:

> On Fri, Feb 15, 2008 at 3:58 PM, Robin Norwood <rnorwood at redhat.com>
> wrote:
> > On Fri, 15 Feb 2008 14:30:53 +0100
> >  Tim Lauridsen <tim.lauridsen at googlemail.com> wrote:
> >
> >  > I spend some time make the yum2 dbus backend work.
> >  >
> >  > Had to comment out all dbus service methods in the base class
> >  > (deamonBackend.py) because it looks like overloading the methods
> >  > in yumDBUSBackend.py was not working, so when calling the
> >  > methods from
> >
> >  Thanks for fixing that up...I thought it was working for me the
> > other night, but tests in the harsh light of day show that it
> > doesn't work for me now either. Any python guys know anything about
> > overloading decorators, and why this wouldn't be working?
> 
> A decorator is an immediately evaluted function. It is evaluated at
> declaration time, not at instance creation time. If it does some magic
> tricks like passing the decorated method to an external library, it
> does the magic on the exact method that it prepends. Also:
> 
> @foo
> def bar:
>     pass
> 
> is equal to:
> 
> def bar:
>     pass
> bar = foo(bar)
> 
> So you really overload the decorator's output, not the original
> method.

Ok...I knew decorators were evaluated 'early', but I'm still not clear
on why this doesn't (seem to) work:

class Foo:
    ...
    
    @decfoo
    def bar:
        pass

class Bar(Foo):
    ...

    @decfoo
    def bar:
        print "Hello world\n"


And what the proper syntax is to get it to do what I want.  In the case
of the signals, I mostly want to use the base class to implement them,
because really all the code for them is in the decorator - I (mostly)
don't need to override them at all.

For the methods, however, we want to use the base class as essentially
an interface, so that someone starting a new dbus-based python backend
knows what functions to implement.  We can live with out this, but it
would make me happy.  But if we ever need to overload one of the
Signals, it would be nice to know how.

Thanks,

-RN

-- 
Robin Norwood
Red Hat, Inc.

"The Sage does nothing, yet nothing remains undone."
-Lao Tzu, Te Tao Ching



More information about the PackageKit mailing list