def evolve(context): root = getRootFolder(context) old_site = getSite() assert ISchoolToolApplication.providedBy(root) setSite(root) requireURICache(root) connection = context.connection link_oids, linkset_oids = collectOIDs(connection) evolveLinks(connection, link_oids) transaction.savepoint(optimistic=True) evolveLinkSets(connection, linkset_oids) transaction.savepoint(optimistic=True) addLinkCatalog(root) transaction.savepoint(optimistic=True) evolveGroupRelationships(root) evolveCourseRelationships(root) evolveResourceRelationships(root) evolveAdvisorRelationships(root) evolveSectionsRelationships(root) transaction.savepoint(optimistic=True) evolveContactRelationships(root) setSite(old_site)
def ensureEvolved(context): root = getRootFolder(context) assert ISchoolToolApplication.providedBy(root) catalogs = root['schooltool.app.catalog:Catalogs'] if LinkCatalog.key() in catalogs: return evolve(context) transaction.commit()
def ensureEvolved(context): root = getRootFolder(context) assert ISchoolToolApplication.providedBy(root) catalogs = root["schooltool.app.catalog:Catalogs"] if LinkCatalog.key() in catalogs: return evolve(context) transaction.commit()
def schoolToolTraverseSubscriber(event): """A subscriber to BeforeTraverseEvent. Adds DevMode layer to the request. """ if (ISchoolToolApplication.providedBy(event.object) and IBrowserRequest.providedBy(event.request)): directlyProvides(event.request, directlyProvidedBy(event.request) + IDevModeLayer)
def getSchoolToolApplication(ignore=None): """Return the nearest ISchoolToolApplication. This function is also registered as an adapter, so you can use it like this: app = ISchoolToolApplication(None) and stub it in unit tests. """ candidate = getSite() if ISchoolToolApplication.providedBy(candidate): return candidate return None
def openDB(self, options): if self.db is not None: return self.db db_configuration = options.config.database db = db_configuration.open() connection = db.open() root = connection.root() app = root.get(ZopePublication.root_name) if app is None or not ISchoolToolApplication.providedBy(app): connection.close() return None connection.close() provideUtility(db, IDatabase) db.setActivityMonitor(ActivityMonitor()) self.db = db return self.db