Beispiel #1
0
    def createNewModule(project, base_name = None):
        all_names = [w.name for w in Module.lookupAll(project=project)]
        now_stamp = time.time()
        if base_name is None:
            base_name = "module"
        name = base_name
        count = 1
        while name in all_names:
            name = base_name+"_%s"%count
            count += 1

        newModule = Module(
            name=name,
            created_timestamp=now_stamp,
            project=project,
            last_modified_timestamp=now_stamp
            )

        cells.sessionState().selected_module = newModule
    def cellsForOnlyExistingModule(self):
        """Find the one module that exists in 'cells' and set the root cell to render it."""
        with self.db.view():
            module_ids_names = [(mod._identity, mod.name) for mod in Module.lookupAll()]

        assert len(module_ids_names) == 1

        module_id = module_ids_names[0][0]

        return self.makeCells(queryArgs={"module" : module_id})
Beispiel #3
0
        def projectView(project):
            expander = cells.Expands(
                closed=ResearchFrontend.projectLine(project),
                open=ResearchFrontend.projectLine(project) +
                    cells.SubscribedSequence(
                        lambda: sorted(Module.lookupAll(project=project), key=lambda m: m.name),
                        lambda m: ResearchFrontend.moduleLine(m)
                        )
                ).tagged(f"RFE_ProjectExpander_{project._identity}")

            def onProjectSelectChanged():
                if (cells.sessionState().selected_module and cells.sessionState().selected_module.exists()
                        and cells.sessionState().selected_module.project == project and not expander.isExpanded):
                    expander.isExpanded = True
                    expander.markDirty()

            return expander + cells.Subscribed(onProjectSelectChanged)
Beispiel #4
0
    def initialize(self, chunkStoreOverride=None):
        self._logger = logging.getLogger(__file__)
        self._connectionCache = {}

        self.db.subscribeToSchema(schema)
        self.db.subscribeToSchema(ContentSchema.schema)
        self.db.subscribeToSchema(EvaluationSchema.schema)

        with self.db.transaction().consistency(full=True):
            if not Project.lookupAny():
                proj = Project(
                    name="project",
                    created_timestamp=time.time(),
                    last_modified_timestamp=time.time()
                    )
                Module(
                    name="doc1",
                    project=proj,
                    created_timestamp=time.time(),
                    last_modified_timestamp=time.time()
                    )
                # create the singleton EvaluationContext object
                EvaluationSchema.EvaluationContext()
 def getModule():
     return Module.lookupAny()
 def getModule():
     return Module.fromIdentity(module_id)