def setUpIntIds(test): from zope.intid import IntIds from zope.intid.interfaces import IIntIds from zope.keyreference.testing import SimpleKeyReference zope.component.provideAdapter(SimpleKeyReference) site = hooks.getSite() if zope.component.interfaces.ISite.providedBy(site): sm = site.getSiteManager() sm['default']['intids'] = intids = IntIds() sm.registerUtility(intids, IIntIds) else: zope.component.provideUtility(IntIds(), IIntIds)
def setUp(self): from zope.site.folder import Folder ReferenceSetupMixin.setUp(self) sm = getSiteManager(self.root) self.utility = addUtility(sm, '1', IIntIds, IntIds()) self.root['folder1'] = Folder() self.root._p_jar = ConnectionStub() self.root['folder1']['folder1_1'] = self.folder1_1 = Folder() self.root['folder1']['folder1_1']['folder1_1_1'] = Folder() sm1_1 = createSiteManager(self.folder1_1) self.utility1 = addUtility(sm1_1, '2', IIntIds, IntIds()) provideHandler(intIdEventNotify)
def _createIntIds(self, site): """Create intids if needed, and return it. """ intids = zope.component.queryUtility(IIntIds, context=site, default=None) if intids is not None: return intids intids = IntIds() setupUtility = zope.component.getUtility( grokcore.site.interfaces.IUtilityInstaller) setupUtility(site, intids, IIntIds) return intids
def setUp(test): testing.setUp(test) # Register adapters and handlers: # This query interface relies on a zope.app.catalog to # do the job. Before we can use this catalog, we'll need to register an # IIntIds utility and wire in a couple of adatpers defined in the # subscribe module. This is what 'create_subscriptions' does for us: from zope.component import provideUtility, provideAdapter, provideHandler for adapter in (subscribe.catalog_data, subscribe.SubscriptionSearchableText): provideAdapter(adapter) from zope.component.event import objectEventNotify for handler in (subscribe.subscription_modified, subscribe.subscription_removed, objectEventNotify): provideHandler(handler) # Set up an IIntIds utility: try: from zope.intid import IntIds from zope.intid.interfaces import IIntIds IntIds, IIntIds # pyflakes except ImportError: # BBB Plone 4.0 and earlier. from zope.app.intid import IntIds from zope.app.intid.interfaces import IIntIds intids = IntIds() provideUtility(intids, IIntIds) # We'll register a slight variation of the subscription_added # handler that commits the transaction, so that a later lookup of # IKeyReference for our subscription will work: from ZODB.DemoStorage import DemoStorage from ZODB import DB global root db = DB(DemoStorage()) root = db.open().root() subscription_added.__component_adapts__ = ( subscribe.subscription_added.__component_adapts__) provideHandler(subscription_added) # As a last step, we'll register the IKeyReference adapter for all # persistent objects: from zope.keyreference.persistent import KeyReferenceToPersistent from persistent.interfaces import IPersistent provideAdapter(KeyReferenceToPersistent, adapts=(IPersistent, )) provideAdapter(subscribe.get_subscription_label) provideAdapter(subscribe.get_subscription_key)
def setUp(self): BrowserTestCase.setUp(self) self.basepath = '/++etc++site/default' root = self.getRootFolder() sm = traverse(root, '/++etc++site') setup.addUtility(sm, 'intid', IIntIds, IntIds()) commit() type_name = 'BrowserAdd__zope.intid.IntIds' response = self.publish(self.basepath + '/contents.html', basic='mgr:mgrpw', form={ 'type_name': type_name, 'new_value': 'mgr' })
def getId(self, ob=_marker): # Compatibility with SimpleItem if ob is _marker: return self.__name__ return z3IntIds.getId(self, ob)
def createIntIds(self): return IntIds(family=BTrees.family64)
def setUp(test): test.globs['root'] = setup.placefulSetUp(site=True) component.provideUtility(IntIds(), IIntIds) component.provideAdapter(testing.SimpleKeyReference)
def setUpIntIds(): provideAdapter(KeyReferenceStub) provideHandler(addIntIdSubscriber, [ILocation, IObjectAddedEvent]) provideUtility(IntIds(), IIntIds) testing_registry.setupTimetablesComponents()
def OFFsetUpIntIds(test): from zope.intid import IntIds from zope.intid.interfaces import IIntIds from zope.keyreference.testing import SimpleKeyReference zope.component.provideAdapter(SimpleKeyReference) zope.component.provideUtility(IntIds(), IIntIds)