def update_menus(dbi): links = ('collaboration', 'downloadETicket') ch = ConferenceHolder() cdmr = ConfDisplayMgrRegistery() counter = Counter() for __, event in conferenceHolderIterator(ch, deepness='event'): menu = cdmr.getDisplayMgr(event).getMenu() must_update = False for linkname in links: if menu.getLinkByName(linkname) is None: counter[linkname] += 1 must_update = True if must_update: menu.updateSystemLink() counter['updated'] += 1 if counter['updated'] % 100: dbi.commit() for linkname in links: print "{} links missing: {}".format(linkname, counter[linkname]) success("Event menus updated: {}".format(counter['updated']))
def update_menus(dbi): links = ("collaboration", "downloadETicket") ch = ConferenceHolder() cdmr = ConfDisplayMgrRegistery() counter = Counter() for __, event in conferenceHolderIterator(ch, deepness="event"): menu = cdmr.getDisplayMgr(event).getMenu() must_update = False for linkname in links: if menu.getLinkByName(linkname) is None: counter[linkname] += 1 must_update = True if must_update: menu.updateSystemLink() counter["updated"] += 1 if counter["updated"] % 100: dbi.commit() for linkname in links: print "{} links missing: {}".format(linkname, counter[linkname]) success("Event menus updated: {}".format(counter["updated"]))
def migrate_legacy_events(self): print cformat('%{white!}migrating legacy events') dmr = ConfDisplayMgrRegistery()._getDisplayMgrRegistery() wfr = WebFactoryRegistry()._getConfRegistry() ipmr = InternalPagesMgrRegistery()._getInternalPagesMgrRegistery() for event in self._committing_iterator(self._get_events()): if not hasattr(event, '_old_id'): new_id = self.gen_event_id() event.unindexConf() del self.zodb_root['conferences'][event.id] dm = dmr.pop(event.id, None) wf = wfr.pop(event.id, None) ipm = ipmr.pop(event.id, None) event._old_id = event.id event.id = new_id if dm is not None: dmr[event.id] = dm if wf is not None: wfr[event.id] = wf if ipm is not None: ipmr[event.id] = ipm self.zodb_root['conferences'][event.id] = event event.indexConf() IndexedEvent.find(id=event._old_id).update({IndexedEvent.id: event.id}) EventSetting.find(event_id=event._old_id).update({EventSetting.event_id: event.id}) EventSettingPrincipal.find(event_id=event._old_id).update({EventSettingPrincipal.event_id: event.id}) db.session.add(LegacyEventMapping(legacy_event_id=event._old_id, event_id=int(event.id))) print cformat('%{green}+++%{reset} ' '%{white!}{:6s}%{reset} %{cyan}{}').format(event._old_id, int(event.id)) else: # happens if this importer was executed before but you want to add the mapping to your DB again db.session.add(LegacyEventMapping(legacy_event_id=event._old_id, event_id=int(event.id))) msg = cformat('%{green}+++%{reset} ' '%{white!}{:6s}%{reset} %{cyan}{}%{reset} %{yellow}(already updated in zodb)') print msg.format(event._old_id, int(event.id))