collective.upgrade 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. collective/upgrade/__init__.py +3 -0
  2. collective/upgrade/broken.py +170 -0
  3. collective/upgrade/broken.zcml +24 -0
  4. collective/upgrade/configure.zcml +8 -0
  5. collective/upgrade/interfaces.py +24 -0
  6. collective/upgrade/pas.py +351 -0
  7. collective/upgrade/pas.rst +442 -0
  8. collective/upgrade/ploneupgrader.py +84 -0
  9. collective/upgrade/portals.py +27 -0
  10. collective/upgrade/profiles/blank/actions.xml +2 -0
  11. collective/upgrade/profiles/blank/archetype_tool.xml +2 -0
  12. collective/upgrade/profiles/blank/browserlayer.xml +2 -0
  13. collective/upgrade/profiles/blank/cachingpolicymgr.xml +2 -0
  14. collective/upgrade/profiles/blank/catalog.xml +2 -0
  15. collective/upgrade/profiles/blank/contentrules.xml +2 -0
  16. collective/upgrade/profiles/blank/contenttyperegistry.xml +2 -0
  17. collective/upgrade/profiles/blank/controlpanel.xml +2 -0
  18. collective/upgrade/profiles/blank/cookieauth.xml +2 -0
  19. collective/upgrade/profiles/blank/cssregistry-bbb.xml +2 -0
  20. collective/upgrade/profiles/blank/cssregistry.xml +2 -0
  21. collective/upgrade/profiles/blank/diff_tool.xml +2 -0
  22. collective/upgrade/profiles/blank/factorytool.xml +2 -0
  23. collective/upgrade/profiles/blank/jsregistry-bbb.xml +2 -0
  24. collective/upgrade/profiles/blank/jsregistry.xml +2 -0
  25. collective/upgrade/profiles/blank/mailhost.xml +3 -0
  26. collective/upgrade/profiles/blank/memberdata_properties.xml +2 -0
  27. collective/upgrade/profiles/blank/portal_atct.xml +2 -0
  28. collective/upgrade/profiles/blank/portal_languages.xml +2 -0
  29. collective/upgrade/profiles/blank/portal_placeful_workflow.xml +2 -0
  30. collective/upgrade/profiles/blank/portlets.xml +2 -0
  31. collective/upgrade/profiles/blank/properties.xml +2 -0
  32. collective/upgrade/profiles/blank/propertiestool.xml +2 -0
  33. collective/upgrade/profiles/blank/reference_catalog.xml +2 -0
  34. collective/upgrade/profiles/blank/registry.xml +2 -0
  35. collective/upgrade/profiles/blank/repositorytool.xml +2 -0
  36. collective/upgrade/profiles/blank/rolemap.xml +4 -0
  37. collective/upgrade/profiles/blank/sharing.xml +2 -0
  38. collective/upgrade/profiles/blank/skins.xml +2 -0
  39. collective/upgrade/profiles/blank/steps.pp +65 -0
  40. collective/upgrade/profiles/blank/toolset.xml +2 -0
  41. collective/upgrade/profiles/blank/types.xml +2 -0
  42. collective/upgrade/profiles/blank/uid_catalog.xml +2 -0
  43. collective/upgrade/profiles/blank/workflows.xml +2 -0
  44. collective/upgrade/profiles/testing/reconcile_groups.csv +10 -0
  45. collective/upgrade/profiles/testing/reconcile_users.csv +7 -0
  46. collective/upgrade/resourceregistries.py +95 -0
  47. collective/upgrade/resourceregistries.zcml +38 -0
  48. collective/upgrade/run.py +178 -0
  49. collective/upgrade/steps.py +352 -0
  50. collective/upgrade/steps.zcml +75 -0
  51. collective/upgrade/testing.py +146 -0
  52. collective/upgrade/testing.zcml +15 -0
  53. collective/upgrade/tests.py +22 -0
  54. collective/upgrade/upgrader.py +117 -0
  55. collective/upgrade/upgraders.zcml +24 -0
  56. collective/upgrade/utils.py +110 -0
  57. collective_upgrade-2.0.0.data/scripts/run-portal-upgrades +4 -0
  58. collective_upgrade-2.0.0.dist-info/METADATA +449 -0
  59. collective_upgrade-2.0.0.dist-info/RECORD +62 -0
  60. collective_upgrade-2.0.0.dist-info/WHEEL +5 -0
  61. collective_upgrade-2.0.0.dist-info/entry_points.txt +5 -0
  62. collective_upgrade-2.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+
3
+ """CMF portal upgrade helpers."""
@@ -0,0 +1,170 @@
1
+ # encoding: utf-8
2
+
3
+ from Acquisition import aq_base, aq_parent
4
+ from Products.CMFCore.utils import getToolByName
5
+ from Products.GenericSetup import utils
6
+ from Products.ZCatalog import ZCatalog
7
+ from ZODB import broken
8
+ from ZODB import interfaces as zodb_ifaces
9
+ from zope import component, interface
10
+
11
+ from collective.upgrade import steps
12
+
13
+
14
+ def cleanupBrokenComponents(context):
15
+ """Delete component registrations from missing add-ons."""
16
+ portal = getToolByName(context, "portal_url").getPortalObject()
17
+ sm = component.getSiteManager(context=portal)
18
+ for reg in list(sm.registeredUtilities()):
19
+ if not isinstance(reg.component, broken.Broken):
20
+ continue
21
+
22
+ steps.logger.info("Unregistering broken utility %r in %r" % (reg, portal))
23
+ sm.unregisterUtility(
24
+ component=reg.component, provided=reg.provided, name=reg.name
25
+ )
26
+
27
+
28
+ def cleanupBrokenSetupRegistrations(context):
29
+ """Delete portal_setup registrations from missing add-ons."""
30
+ setup = getToolByName(context, "portal_setup")
31
+ required = setup.getToolsetRegistry()._required
32
+ for id_, tool in list(required.items()):
33
+ if utils._resolveDottedName(tool["class"]) is None:
34
+ steps.logger.info(
35
+ "Unregistering missing required tool %r in %r" % (tool, setup)
36
+ )
37
+ required.pop(id_)
38
+ setup._p_changed = True
39
+
40
+ for info in setup.listProfileInfo():
41
+ profile_id = "profile-" + info["id"]
42
+ # Update a broken import step depdendency in the
43
+ # persisent registry which has been fixed in the
44
+ # profile import_steps.xml
45
+ steps.logger.info("Applying profile context %r in %r" % (profile_id, setup))
46
+ setup.applyContextById(profile_id)
47
+
48
+
49
+ class Empty(object):
50
+ pass
51
+
52
+
53
+ def cleanupBrokenTextIndexes(context):
54
+ catalog = getToolByName(context, "portal_catalog")
55
+ for id_ in catalog.indexes():
56
+ index = catalog._catalog.getIndex(id_)
57
+ if (
58
+ not isinstance(index, broken.Broken)
59
+ or "TextIndex" not in index.__class__.__name__
60
+ ):
61
+ continue
62
+
63
+ steps.logger.info("Replacing %r text index in %r" % (index, catalog))
64
+ catalog.manage_delIndex(id_)
65
+ extras = Empty()
66
+ extras.index_type = "Okapi BM25 Rank"
67
+ extras.lexicon_id = "plone_lexicon"
68
+ catalog.addIndex(id_, "ZCTextIndex", extras)
69
+
70
+
71
+ class CleanupBrokenObjects(steps.CMFEditionsUpgrader):
72
+
73
+ catalog_ids = ("portal_catalog", "uid_catalog", "reference_catalog")
74
+ update_catalogs = True
75
+
76
+ def upgrade(self):
77
+ self.upgradeObjects()
78
+
79
+ # Cleanup broken CMFEditions versions
80
+ super(CleanupBrokenObjects, self).upgrade()
81
+
82
+ def upgradeObjects(self):
83
+ # Clear the catalogs before walking the objects. Objects will
84
+ # be indexed in the catalogs after being cleaned.
85
+ for zcatalog_id in self.catalog_ids:
86
+ zcatalog = getToolByName(self.context, zcatalog_id, None)
87
+ if zcatalog is not None:
88
+ self.log("Clearing the %r catalog" % zcatalog)
89
+ zcatalog.manage_catalogClear()
90
+ else:
91
+ self.log("Could not find the %r catalog, skipping." % zcatalog_id)
92
+
93
+ # Some broken objects may be transforms which require special handling
94
+ self.trans_tool = getToolByName(self.context, "portal_transforms", None)
95
+
96
+ # Walk all the portal objects fixing problems which might
97
+ # stop the upgrades.
98
+ self.log("Begin cleaning up objects in %r" % self.context)
99
+ self.context.ZopeFindAndApply(
100
+ self.context, search_sub=1, apply_func=self.upgradeObj
101
+ )
102
+
103
+ # There should be no more broken interfaces
104
+ catalog = getToolByName(self.context, "portal_catalog")
105
+ assert len(catalog(object_provides=zodb_ifaces.IBroken.__identifier__)) == 0
106
+
107
+ def upgradeObj(self, obj, path=None):
108
+ obj._p_activate()
109
+
110
+ if self.delRemovedObj(obj, path):
111
+ # Deleted don't do anything else
112
+ return
113
+
114
+ if "__implements__" in obj.__dict__:
115
+ self.log("Deleting __implements__ instance attributre from %r" % obj)
116
+ del obj.__dict__["__implements__"]
117
+ obj._p_changed = True
118
+
119
+ if zodb_ifaces.IBroken.providedBy(obj):
120
+ self.log(
121
+ "Removing broken interfaces from %r: %r"
122
+ % (obj, list(interface.directlyProvidedBy(obj)))
123
+ )
124
+ interface.noLongerProvides(obj, zodb_ifaces.IBroken)
125
+
126
+ if not self.update_catalogs:
127
+ return
128
+ base = aq_base(obj)
129
+
130
+ if not isinstance(obj, ZCatalog.ZCatalog) and callable(
131
+ getattr(base, "indexObject", None)
132
+ ):
133
+ obj.indexObject()
134
+
135
+ if callable(getattr(base, "_updateCatalog", None)):
136
+ obj._updateCatalog(obj)
137
+
138
+ def delRemovedObj(self, obj, path=None):
139
+ """Delete broken objects."""
140
+ if not isinstance(obj, broken.Broken):
141
+ return
142
+
143
+ if path is None:
144
+ path = "/".join(obj.getPhysicalPath())
145
+ obj_id = path.rsplit("/", 1)[-1]
146
+ container = aq_parent(obj)
147
+
148
+ if aq_base(container) is aq_base(self.trans_tool):
149
+ self.log("Unregistering broken transform: %s" % path)
150
+ self.unmapTransform(container, obj)
151
+
152
+ self.log("Deleting broken object: %s" % path)
153
+ container.manage_delObjects([obj_id])
154
+ assert container._getOb(obj_id, None) is None
155
+
156
+ return obj_id
157
+
158
+ def unmapTransform(self, container, transform):
159
+ """unmap transform from portal_transforms structures"""
160
+ for dest in container._mtmap.values():
161
+ for transforms in dest.values():
162
+ for registered in transforms:
163
+ if aq_base(registered) is aq_base(transform):
164
+ transforms.remove(transform)
165
+ container._p_changed = True
166
+
167
+
168
+ def cleanupBrokenObjects(context):
169
+ upgrader = CleanupBrokenObjects(context)
170
+ upgrader.upgrade()
@@ -0,0 +1,24 @@
1
+ <configure
2
+ xmlns="http://namespaces.zope.org/zope"
3
+ xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
4
+ i18n_domain="plone">
5
+
6
+ <genericsetup:upgradeSteps
7
+ source="*"
8
+ destination="4001"
9
+ profile="Products.CMFPlone:plone">
10
+ <genericsetup:upgradeStep
11
+ title="Cleanup missing component registrations."
12
+ handler=".broken.cleanupBrokenComponents" />
13
+ <genericsetup:upgradeStep
14
+ title="Cleanup missing portal_setup registrations."
15
+ handler=".broken.cleanupBrokenSetupRegistrations" />
16
+ <genericsetup:upgradeStep
17
+ title="Cleanup broken TextIndexes such as from TextIndexNG."
18
+ handler=".broken.cleanupBrokenTextIndexes" />
19
+ <genericsetup:upgradeStep
20
+ title="Cleanup broken objects."
21
+ handler=".broken.cleanupBrokenObjects" />
22
+ </genericsetup:upgradeSteps>
23
+
24
+ </configure>
@@ -0,0 +1,8 @@
1
+ <configure xmlns="http://namespaces.zope.org/zope">
2
+
3
+ <include package="Products.CMFCore" file="permissions.zcml" />
4
+
5
+ <include file="upgraders.zcml" />
6
+ <include file="steps.zcml" />
7
+
8
+ </configure>
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ from zope import interface
4
+
5
+
6
+ class IUpgrader(interface.Interface):
7
+ """Upgrade a context."""
8
+
9
+ logger = interface.Attribute("The logger used to record upgrade information.")
10
+ log_level = interface.Attribute(
11
+ 'The default "logging" module level for log messages.'
12
+ )
13
+ log_template = interface.Attribute(
14
+ "The string formatting template used for log messagess."
15
+ )
16
+
17
+ def __call__():
18
+ """Do the actual upgrade work."""
19
+
20
+ def log(msg, level=None, template=None):
21
+ """Log a message using the template and level."""
22
+
23
+ def commit(note="Checkpointing upgrade"):
24
+ """Commit with a transaction note and log a message."""
@@ -0,0 +1,351 @@
1
+ # encoding: utf-8
2
+
3
+ import csv
4
+ import io
5
+ import logging
6
+ import mimetypes
7
+
8
+ import transaction
9
+ from AccessControl import owner
10
+ from Products.CMFCore.utils import getToolByName
11
+ from Products.PluggableAuthService.interfaces.plugins import (
12
+ IGroupEnumerationPlugin, IGroupsPlugin, IPropertiesPlugin,
13
+ IUserEnumerationPlugin)
14
+
15
+ logger = logging.getLogger("collective.upgrade.pas")
16
+
17
+
18
+ class Reconciler(object):
19
+
20
+ filename = "reconcile_{0}s.csv"
21
+
22
+ def __init__(self, context, principal_type):
23
+ self.context = context
24
+ self.site = context.getSite()
25
+
26
+ principal_type = principal_type.lower()
27
+ self.principal_type = principal_type
28
+ self.filename = self.filename.format(principal_type)
29
+
30
+
31
+ class ExportReconciler(Reconciler):
32
+
33
+ fieldnames = (
34
+ "Source Plugin ID",
35
+ "Source ID",
36
+ "Destination Plugin ID",
37
+ "Destination ID",
38
+ "Destination Duplicate IDs",
39
+ )
40
+ user_properties = ("fullname",)
41
+
42
+ def __init__(
43
+ self,
44
+ context,
45
+ principal_type,
46
+ dest_users_plugin=None,
47
+ dest_properties_plugin=None,
48
+ dest_groups_plugin=None,
49
+ ):
50
+ super(ExportReconciler, self).__init__(context, principal_type)
51
+ self.acl_users = getToolByName(self.site, "acl_users")
52
+ self.plugins = self.acl_users._getOb("plugins")
53
+
54
+ self.get_rows = getattr(self, "get_{0}_rows".format(self.principal_type))
55
+
56
+ if principal_type == "user":
57
+ if not dest_users_plugin:
58
+ dest_users_plugin = self.plugins.listPlugins(IUserEnumerationPlugin)[0][
59
+ 0
60
+ ]
61
+ self.dest_users = self.acl_users._getOb(dest_users_plugin)
62
+ if not dest_properties_plugin:
63
+ dest_properties_plugin = self.plugins.listPlugins(IPropertiesPlugin)[0][
64
+ 0
65
+ ]
66
+ self.dest_properties = self.acl_users._getOb(dest_properties_plugin)
67
+ else:
68
+ if not dest_groups_plugin:
69
+ dest_groups_plugin = self.plugins.listPlugins(IGroupEnumerationPlugin)[
70
+ 0
71
+ ][0]
72
+ self.dest_groups = self.acl_users._getOb(dest_groups_plugin)
73
+
74
+ def export_rows(self):
75
+ if hasattr(self.context, "openDataFile"):
76
+ csvfile = self.context.openDataFile(self.filename)
77
+ else:
78
+ csvfile = io.StringIO()
79
+
80
+ try:
81
+ content_type = mimetypes.guess_type(self.filename)
82
+ writer = csv.DictWriter(csvfile, self.fieldnames)
83
+ writer.writerow(dict((name, name) for name in self.fieldnames))
84
+ writer.writerows(self.get_rows())
85
+
86
+ if not hasattr(self.context, "openDataFile"):
87
+ csvfile.seek(0)
88
+ self.context.writeDataFile(self.filename, csvfile.read(), content_type)
89
+
90
+ finally:
91
+ csvfile.close()
92
+
93
+ def get_user_rows(self):
94
+ seen = set()
95
+ # Temporarily disable the destination plugins from listing
96
+ savepoint = transaction.savepoint(optimistic=True)
97
+ try:
98
+ self.plugins.deactivatePlugin(
99
+ IUserEnumerationPlugin, self.dest_users.getId()
100
+ )
101
+ if self.dest_properties.getId() in self.plugins.listPluginIds(
102
+ IUserEnumerationPlugin
103
+ ):
104
+ self.plugins.deactivatePlugin(
105
+ IUserEnumerationPlugin, self.dest_properties.getId()
106
+ )
107
+
108
+ # Look for matches for the source users
109
+ for info in self.acl_users.searchUsers():
110
+ if info["id"] in seen:
111
+ continue
112
+ seen.add(info["id"])
113
+ result = {"Source Plugin ID": info["pluginid"], "Source ID": info["id"]}
114
+
115
+ # Exact user id match
116
+ matches = self.dest_users.enumerateUsers(
117
+ id=info["id"], exact_match=True
118
+ )
119
+ if len(matches) == 1:
120
+ result["Destination Plugin ID"] = matches[0].get(
121
+ "pluginid", self.dest_users.getId()
122
+ )
123
+ result["Destination ID"] = matches[0]["id"]
124
+ yield result
125
+ continue
126
+
127
+ # Match on properties
128
+ user = self.acl_users.getUserById(info["id"])
129
+ value = None
130
+ if user is not None:
131
+ for prop in self.user_properties:
132
+ prop_result = result.copy()
133
+ value = None
134
+ for sheet_id in user.listPropertysheets():
135
+ sheet = user.getPropertysheet(sheet_id)
136
+ if sheet.hasProperty(prop):
137
+ value = sheet.getProperty(prop)
138
+ if value:
139
+ break
140
+ else:
141
+ continue
142
+ matches = self.dest_properties.enumerateUsers(**{prop: value})
143
+ if matches:
144
+ prop_result["Destination Plugin ID"] = matches[0].get(
145
+ "pluginid", self.dest_users.getId()
146
+ )
147
+ prop_result["Destination ID"] = matches[0]["id"]
148
+ if len(matches) > 1:
149
+ prop_result["Destination Duplicate IDs"] = " ".join(
150
+ match["id"] for match in matches[1:]
151
+ )
152
+ yield prop_result
153
+
154
+ # No match
155
+ if not value:
156
+ yield result
157
+
158
+ # Restore disabled plugins
159
+ finally:
160
+ savepoint.rollback()
161
+
162
+ def get_group_rows(self):
163
+ seen = set()
164
+ # Temporarily disable the destination plugins from listing
165
+ savepoint = transaction.savepoint(optimistic=True)
166
+ try:
167
+ self.plugins.deactivatePlugin(
168
+ IGroupEnumerationPlugin, self.dest_groups.getId()
169
+ )
170
+
171
+ # Look for matches for the source groups
172
+ for info in self.acl_users.searchGroups():
173
+ if info["id"] in seen:
174
+ continue
175
+ seen.add(info["id"])
176
+ result = {"Source Plugin ID": info["pluginid"], "Source ID": info["id"]}
177
+
178
+ # Exact group id match
179
+ matches = self.dest_groups.enumerateGroups(
180
+ id=info["id"], exact_match=True
181
+ )
182
+ if len(matches) == 1:
183
+ result["Destination Plugin ID"] = matches[0].get(
184
+ "pluginid", self.dest_groups.getId()
185
+ )
186
+ result["Destination ID"] = matches[0]["id"]
187
+ yield result
188
+ continue
189
+
190
+ # Match on group title
191
+ if info.get("title"):
192
+ matches = self.dest_groups.enumerateGroups(title=info["title"])
193
+ if matches:
194
+ result["Destination Plugin ID"] = matches[0].get(
195
+ "pluginid", self.dest_groups.getId()
196
+ )
197
+ result["Destination ID"] = matches[0]["id"]
198
+ if len(matches) > 1:
199
+ result["Destination Duplicate IDs"] = " ".join(
200
+ match["id"] for match in matches[1:]
201
+ )
202
+ yield result
203
+ continue
204
+
205
+ # No match
206
+ yield result
207
+
208
+ # Restore disabled plugins
209
+ finally:
210
+ savepoint.rollback()
211
+
212
+
213
+ class ImportReconciler(Reconciler):
214
+
215
+ def import_rows(self):
216
+ if hasattr(self.context, "openDataFile"):
217
+ csvfile = self.context.openDataFile(self.filename)
218
+ if csvfile is None:
219
+ return
220
+ else:
221
+ datafile = self.context.readDataFile(self.filename)
222
+ if datafile is None:
223
+ return
224
+ csvfile = io.StringIO(datafile)
225
+ decoded_file = io.TextIOWrapper(csvfile, encoding="utf-8")
226
+ reader = csv.DictReader(decoded_file)
227
+
228
+ self.acl_users = getToolByName(self.site, "acl_users")
229
+ self.plugins = self.acl_users._getOb("plugins")
230
+
231
+ getPrincipalById = getattr(
232
+ self.acl_users, "get{0}ById".format(self.principal_type.capitalize())
233
+ )
234
+ rows = {}
235
+ for row in reader:
236
+ dest_id = row.get("Destination ID")
237
+ source_id = row["Source ID"]
238
+ if not dest_id or source_id == dest_id:
239
+ continue
240
+ rows[source_id] = dest_id
241
+ source_principal = getPrincipalById(source_id)
242
+
243
+ groupmakers = self.plugins.listPlugins(IGroupsPlugin)
244
+ for groupmaker_id, groupmaker in groupmakers:
245
+ if not hasattr(groupmaker, "addPrincipalToGroup"):
246
+ continue
247
+ groups = groupmaker.getGroupsForPrincipal(source_principal)
248
+ for group in groups:
249
+ logger.info(
250
+ "Changing group %r member from %r to %r",
251
+ group,
252
+ source_principal.getId(),
253
+ dest_id,
254
+ )
255
+ groupmaker.addPrincipalToGroup(dest_id, group)
256
+ groupmaker.removePrincipalFromGroup(source_principal.getId(), group)
257
+
258
+ acl_users_path = owner.ownerInfo(self.plugins)[0]
259
+
260
+ def import_ofs_obj(
261
+ obj,
262
+ path=None,
263
+ acl_users_path=acl_users_path,
264
+ rows=rows,
265
+ getPrincipalById=getPrincipalById,
266
+ ):
267
+ userdb_path, user_id = obj.getOwnerTuple()
268
+
269
+ creators = getattr(obj, "listCreators", [])
270
+ if callable(creators):
271
+ orig_creators = creators()
272
+ creators = list(orig_creators)
273
+ contributors = getattr(obj, "listContributors", [])
274
+ if callable(contributors):
275
+ orig_contributors = contributors()
276
+ contributors = list(orig_contributors)
277
+
278
+ for source_id, dest_id in rows.items():
279
+ # ownership
280
+ if (acl_users_path, source_id) == (userdb_path, user_id):
281
+ logger.info(
282
+ "Changing %r owner from %r to %r", obj, source_id, dest_id
283
+ )
284
+ dest_principal = getPrincipalById(dest_id)
285
+ obj.changeOwnership(dest_principal)
286
+
287
+ # local roles
288
+ local_roles = obj.get_local_roles_for_userid(source_id)
289
+ if local_roles:
290
+ logger.info(
291
+ "Changing %r local roles %r from %r to %r",
292
+ obj,
293
+ local_roles,
294
+ source_id,
295
+ dest_id,
296
+ )
297
+ obj.manage_addLocalRoles(dest_id, local_roles)
298
+ obj.manage_delLocalRoles([source_id])
299
+
300
+ # CMF creators and contributors
301
+ if source_id in creators:
302
+ creators[creators.index(source_id)] = dest_id
303
+ if source_id in contributors:
304
+ contributors[contributors.index(source_id)] = dest_id
305
+
306
+ creators = tuple(creators)
307
+ if creators != orig_creators:
308
+ logger.info(
309
+ "Changing %r creators from %r to %r", obj, orig_creators, creators
310
+ )
311
+ obj.setCreators(creators)
312
+ contributors = tuple(contributors)
313
+ if contributors != orig_contributors:
314
+ logger.info(
315
+ "Changing %r contributors from %r to %r",
316
+ obj,
317
+ orig_contributors,
318
+ contributors,
319
+ )
320
+ obj.setContributors(contributors)
321
+
322
+ if rows:
323
+ self.site.ZopeFindAndApply(self.site, apply_func=import_ofs_obj)
324
+
325
+
326
+ class DataFile(object):
327
+
328
+ def __init__(self, file_):
329
+ self.size = file_.tell()
330
+ file_.seek(0)
331
+ self.file = file_
332
+
333
+
334
+ def reconcileUsersExport(context):
335
+ reconciler = ExportReconciler(context, "user")
336
+ reconciler.export_rows()
337
+
338
+
339
+ def reconcileGroupsExport(context):
340
+ reconciler = ExportReconciler(context, "group")
341
+ reconciler.export_rows()
342
+
343
+
344
+ def reconcileUsersImport(context):
345
+ reconciler = ImportReconciler(context, "user")
346
+ reconciler.import_rows()
347
+
348
+
349
+ def reconcileGroupsImport(context):
350
+ reconciler = ImportReconciler(context, "group")
351
+ reconciler.import_rows()