Cannot delegate multiple interfaces on a given class

Bug #319716 reported by Aaron Bentley
4
Affects Status Importance Assigned to Milestone
lazr.delegates
Fix Released
Wishlist
Unassigned

Bug Description

If delegates is used twice in a class definition, things explode:
$ ./test.py -v test_branchmergeproposal -t ReviewDiffJob
Traceback (most recent call last):
  File "./test.py", line 175, in ?
    from canonical.testing import profiled
  File "/home/abentley/launchpad/web-bmp-diffs/importfascist.py", line 155, in import_fascist
    module = original_import(name, globals, locals, fromlist)
  File "/home/abentley/launchpad/web-bmp-diffs/lib/canonical/testing/__init__.py", line 67, in ?
    from canonical.testing.layers import *
  File "/home/abentley/launchpad/web-bmp-diffs/importfascist.py", line 155, in import_fascist
    module = original_import(name, globals, locals, fromlist)
  File "/home/abentley/launchpad/web-bmp-diffs/lib/canonical/testing/layers.py", line 87, in ?
    from canonical.launchpad.testing.tests.googleserviceharness import (
  File "/home/abentley/launchpad/web-bmp-diffs/importfascist.py", line 155, in import_fascist
    module = original_import(name, globals, locals, fromlist)
  File "/home/abentley/launchpad/web-bmp-diffs/lib/canonical/launchpad/testing/__init__.py", line 16, in ?
    from canonical.launchpad.testing.factory import *
  File "/home/abentley/launchpad/web-bmp-diffs/importfascist.py", line 155, in import_fascist
    module = original_import(name, globals, locals, fromlist)
  File "/home/abentley/launchpad/web-bmp-diffs/lib/canonical/launchpad/testing/factory.py", line 31, in ?
    from canonical.launchpad.database.message import Message, MessageChunk
  File "/home/abentley/launchpad/web-bmp-diffs/importfascist.py", line 155, in import_fascist
    module = original_import(name, globals, locals, fromlist)
  File "/home/abentley/launchpad/web-bmp-diffs/lib/canonical/launchpad/database/__init__.py", line 17, in ?
    from canonical.launchpad.database.product import *
  File "/home/abentley/launchpad/web-bmp-diffs/importfascist.py", line 155, in import_fascist
    module = original_import(name, globals, locals, fromlist)
  File "/home/abentley/launchpad/web-bmp-diffs/lib/canonical/launchpad/database/product.py", line 32, in ?
    from canonical.launchpad.database.branch import BranchSet
  File "/home/abentley/launchpad/web-bmp-diffs/importfascist.py", line 155, in import_fascist
    module = original_import(name, globals, locals, fromlist)
  File "/home/abentley/launchpad/web-bmp-diffs/lib/canonical/launchpad/database/branch.py", line 70, in ?
    from canonical.launchpad.database.branchmergeproposal import (
  File "/home/abentley/launchpad/web-bmp-diffs/importfascist.py", line 155, in import_fascist
    module = original_import(name, globals, locals, fromlist)
  File "/home/abentley/launchpad/web-bmp-diffs/lib/canonical/launchpad/database/branchmergeproposal.py", line 799, in ?
    class ReviewDiffJob(object):
  File "/home/abentley/launchpad/trunk/lib/zope/interface/advice.py", line 132, in advise
    return callback(newClass)
  File "/usr/lib/python2.4/site-packages/PIL/__init__.py", line 77, in _delegates_advice

KeyError: '__delegates_advice_data__'

There should be a way to delegate multiple interfaces. Ideally, by invoking delegates twice in a class definition, so that varying contexts can be used.

It would also be nice to be able to delegate all interfaces provided by a context object, also. This would help when using delegates as a form of pseudo-inheritance.

Revision history for this message
Curtis Hovey (sinzui) wrote :

I have experienced this too. I agree this would be a nice feature for composing classes of many small parts. I believe the delegates() requires an additional argument that provides a namespace for the private attributes. This may be implicitly knowable using context, because only one delegate can use the context attribute, any other would need to use another attribute.

Changed in lazr.delegates:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Barry Warsaw (barry) wrote :

With Gary's MP landed 5+ years ago, I think this bug is fixed! If you disagree, please re-open.

Changed in lazr.delegates:
status: Triaged → Fix Released
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.