Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(9)  |  Call(7)  |  Derive(0)  |  Import(2)

src/a/r/archetypes.markerfield-1.1/archetypes/markerfield/field.py   archetypes.markerfield(Download)
from Products.Archetypes.atapi import BooleanField
 
from archetypes.schemaextender.field import ExtensionField
from archetypes.markerfield.utils import addMarkerInterface
from archetypes.markerfield.utils import removeMarkerInterface
    def set(self, instance, value, **kwargs):
        if value:
            addMarkerInterface(instance, *self.interfaces)
        else:
            removeMarkerInterface(instance, *self.interfaces)

src/a/r/archetypes.markerfield-1.1/archetypes/markerfield/tests/testUtils.py   archetypes.markerfield(Download)
from zope.interface import providedBy
 
from archetypes.markerfield.utils import addMarkerInterface
from archetypes.markerfield.utils import removeMarkerInterface
 
    def testAddNothing(self):
        obj=Mock()
        addMarkerInterface(obj)
        self.assertEqual(self.ifaces(obj), [])
 
    def testAddSingleInterface(self):
        obj=Mock()
        addMarkerInterface(obj, MarkerInterface)
    def testAddMultipleInterfaces(self):
        obj=Mock()
        addMarkerInterface(obj, MarkerInterface, SecondMarkerInterface)
        self.assertEqual(self.ifaces(obj),
            ["MarkerInterface", "SecondMarkerInterface"])
 
    def testAddAdditionalInterface(self):
        obj=MockWithInterface()
        addMarkerInterface(obj, MarkerInterface)