def add_intids(context): # We need to explicilty use the zope.intids interface and # the zope.app.intids one addUtility(context, IIntIds, IntIds, ofs_name='intids', findroot=False) addUtility(context, app_IIntIds, IntIds, ofs_name='intids', findroot=False)
def add_relations(context): addUtility( context, ICatalog, relation_catalog_factory, ofs_name='relations', findroot=False, )
def afterSetUp(self): addUtility(self.portal, IIntIds, IntIds, ofs_name='intids', findroot=False) setRoles(self.portal, TEST_USER_ID, ['Manager'])
def afterSetUp(self): addUtility(self.portal, IIntIds, IntIds, ofs_name='intids', findroot=False) self.populateSite()
def add_relations(context): addUtility(context, interfaces.IComplexRelationshipContainer, Z2RelationshipContainer, name='relations', findroot=False) # Set __name__ to the silly name given by the old component machinery: util = getUtility(interfaces.IComplexRelationshipContainer, name='relations', context=context) util.__name__ = interfaces.IComplexRelationshipContainer.getName() + \ '-relations' setSite(context) setHooks() intids = getUtility(IIntIds)
def installUtilities(context): if context.readDataFile( 'tn.plonehtmlimagecache-install-utilities.txt') is None: return portal = context.getSite() addUtility(portal, interfaces.IContextKeys, ContextKeys, ofs_name=CONTEXT_KEYS_ID, findroot=False) addUtility(portal, interfaces.ICache, Cache, ofs_name=CACHE_ID, findroot=False)
def test_relations_are_migrated(self): from plone.app.contenttypes.migration.migration import ( restoreReferences, migrate_documents, ) # IIntIds is not registered in the test env. So register it here sm = getSiteManager(self.portal) addUtility(sm, IIntIds, IntIds, ofs_name='intids', findroot=False) # create ATDocuments self.portal.invokeFactory('Document', 'doc1') at_doc1 = self.portal['doc1'] self.portal.invokeFactory('Document', 'doc2') at_doc2 = self.portal['doc2'] self.portal.invokeFactory('Document', 'doc3') at_doc3 = self.portal['doc3'] self.portal.invokeFactory('News Item', 'newsitem') at_newsitem = self.portal['newsitem'] # relate them at_doc1.setRelatedItems([at_doc2]) at_doc2.setRelatedItems([at_newsitem, at_doc3, at_doc1]) at_doc3.setRelatedItems(at_doc1) # migrate content applyProfile(self.portal, 'plone.app.contenttypes:default') migrate_documents(self.portal) dx_doc1 = self.portal['doc1'] dx_doc2 = self.portal['doc2'] dx_doc3 = self.portal['doc3'] # migrate references restoreReferences(self.portal) # assert single references dx_doc1_related = [x.to_object for x in dx_doc1.relatedItems] self.assertEqual(dx_doc1_related, [dx_doc2]) dx_doc3_related = [x.to_object for x in dx_doc3.relatedItems] self.assertEqual(dx_doc3_related, [dx_doc1]) # assert multi references, order is restored dx_doc2_related = [x.to_object for x in dx_doc2.relatedItems] self.assertEqual(dx_doc2_related, [at_newsitem, dx_doc3, dx_doc1])
def test_relations_are_migrated(self): from Products.ATContentTypes.content.document import ATDocument from plone.app.contenttypes.migration.migration import DocumentMigrator # IIntIds is not registered in the test env. So register it here sm = getSiteManager(self.portal) addUtility(sm, IIntIds, IntIds, ofs_name='intids', findroot=False) # create three ATDocument at_doc1 = self.createATCTobject(ATDocument, 'doc1') at_doc2 = self.createATCTobject(ATDocument, 'doc2') at_doc3 = self.createATCTobject(ATDocument, 'doc3') # relate them at_doc1.setRelatedItems([at_doc2.UID(), ]) at_doc2.setRelatedItems([at_doc1, at_doc3]) at_doc3.setRelatedItems(at_doc1) # migrate migrator = self.get_migrator(at_doc1, DocumentMigrator) migrator.migrate() migrator = self.get_migrator(at_doc2, DocumentMigrator) migrator.migrate() migrator = self.get_migrator(at_doc3, DocumentMigrator) migrator.migrate() restoreReferences(self.portal) # assertions new_doc1 = self.portal['doc1'] new_doc2 = self.portal['doc2'] new_doc3 = self.portal['doc3'] self.assertEqual(len(new_doc1.relatedItems), 1) rel1 = new_doc1.relatedItems[0] self.assertEqual(rel1.to_object, new_doc2) self.assertEqual(len(new_doc2.relatedItems), 2) rel1 = new_doc2.relatedItems[0] rel2 = new_doc2.relatedItems[1] self.assertEqual( set([rel1.to_object, rel2.to_object]), set([new_doc1, new_doc3])) self.assertEqual(len(new_doc3.relatedItems), 1) rel1 = new_doc3.relatedItems[0] self.assertEqual(rel1.to_object, new_doc1)
def add_intids(context): addUtility(context, IIntIds, IntIds, ofs_name='intids', findroot=False)
def afterSetUp(self): sm = getSiteManager(self.portal) addUtility(sm, IIntIds, IntIds, ofs_name='intids', findroot=False) setRoles(self.portal, TEST_USER_ID, ['Manager'])
def afterSetUp(self): addUtility( self.portal, IIntIds, IntIds, ofs_name='intids', findroot=False) self.populateSite()
def addIntids(context): addUtility(context, IIntIds, IntIds, ofs_name='intids', findroot=False)
def add_relations(context): addUtility(context, ICatalog, RelationCatalog, ofs_name='relations', findroot=False)
def add_intids(context): addUtility(context, IIntIds, IntIds, ofs_name="intids", findroot=False)
def add_relations(context): addUtility(context, ICatalog, RelationCatalog, ofs_name="relations", findroot=False)
def afterSetUp(self): sm = getSiteManager(self.portal) addUtility(sm, IIntIds, IntIds, ofs_name='intids', findroot=False) self.populateSite()
def install(self): addUtility(self.context, IDefaultRedirectInfo, redirect.DefaultRedirectInfo, findroot=False) logger.info("Persistent default host information installed.")