No way to inherit permissions of built-in types in subtypes.

Bug #694057 reported by Gavin Panella
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
Low
Unassigned

Bug Description

Subclasses of frozenset don't appear to be magically granted those
permissions given to frozenset, and there doesn't seem to be a
ready-made interface for frozenset that I could inherit from. (There
is IFrozenSet in zope.schema but it's an IField subclass.)

The frozenset checker can be obtained by calling:

  from zope.security import checker
  checker = checker.getCheckerForInstancesOf(frozenset)

It defines permissions for the following names:

  __and__ __contains__ __eq__ __ge__ __gt__ __iter__ __le__ __len__
  __lt__ __ne__ __or__ __rand__ __ror__ __rsub__ __rxor__ __str__
  __sub__ __xor__ copy difference intersection issubset issuperset
  symmetric_difference union

I could define an interface for this and use it when declaring
permissions on my subtype, or when defining the interface for my
subtype. This seems... wrong, but would work okay. I suppose I could
write a test to ensure that the interface definition keeps up-to-date
with the names defined in Zope's default frozenset checker.

Anyway, without this interface, writing ZCML becomes tedious. For now
I've opted for registering custom checkers (see lp_sitecustomize for
some other jiggery pokery in the same vein) while I seek a better
solution.

Here's my hack:

  from zope.security import checker
  checker_for_frozen_set = checker.getCheckerForInstancesOf(frozenset)
  checker_for_subscriber_set = checker.NamesChecker(["sorted"])
  checker_for_subscription_set = checker.NamesChecker(
      ["sorted", "subscribers"])
  checker.BasicTypes[BugSubscriberSet] = checker.MultiChecker(
      (checker_for_frozen_set.get_permissions,
       checker_for_subscriber_set.get_permissions))
  checker.BasicTypes[BugSubscriptionSet] = checker.MultiChecker(
      (checker_for_frozen_set.get_permissions,
       checker_for_subscription_set.get_permissions))
  checker.BasicTypes[StructuralSubscriptionSet] = checker.MultiChecker(
      (checker_for_frozen_set.get_permissions,
       checker_for_subscription_set.get_permissions))

Tags: zope
Curtis Hovey (sinzui)
Changed in launchpad:
status: New → Triaged
importance: Undecided → Low
tags: added: zope
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.