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

All Samples(6)  |  Call(4)  |  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 archetypes.markerfield.utils import addMarkerInterface
from archetypes.markerfield.utils import removeMarkerInterface
 
 
    def testRemoveNonPresentInterface(self):
        obj=Mock()
        removeMarkerInterface(obj, MarkerInterface)
        self.assertEqual(self.ifaces(obj), [])
 
    def testAddAndRemoveSingleInterface(self):
        obj=Mock()
        addMarkerInterface(obj, MarkerInterface)
        removeMarkerInterface(obj, MarkerInterface)
    def testAddTwoInterfacesAndRemoveOne(self):
        obj=Mock()
        addMarkerInterface(obj, MarkerInterface, SecondMarkerInterface)
        removeMarkerInterface(obj, MarkerInterface)
        self.assertEqual(self.ifaces(obj), ["SecondMarkerInterface"])