not easy/possible to write 'make resource dirty' decorator

Bug #500214 reported by Robert Collins
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
testresources
Triaged
Wishlist
Unassigned

Bug Description

I want to be able to write code roughly like:

class _Decorated(object):
    """A decorated resource."""

    def __add__(self, other):
        return self.decorated.__add__(other)

    def __getattr__(self, name):
        return getattr(self.decorated, name)

class AlwaysDirtyResourceDecorator(TestResource):
    """A resource decorator that makes another resource dirty."""

    def __init__(self, decorated):
        TestResource.__init__(self)
        self.resources = [('decorated', decorated)]
        self._dirty = True

    def make(self, dependency_resources):
        self.resource = _Decorated()
        self.resources[0][1].dirtied(dependency_resources['decorated'])
        return self.resource

    def clean(self, resource):
        self.resource = None

    def isDirty(self):
        self.resources[0][1].dirtied(self.resource.decorated)
        return True

but it doesn't work today; permitting decoration like this would be very useful.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.