예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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()
예제 #4
0
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()
예제 #5
0
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)
예제 #6
0
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
예제 #7
0
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
예제 #8
0
 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