def new(pid, name, content): """ pre: id, unique time post: a new page id is added to g. The user is added as owner and to the whitelist and a first version of the document is created. """ # Initialisation did = globals.newdid() # Create initial nodes globals.g.add((edodoc[str(did)], edodoc["type"], Literal("document"))) # Setting owner, reverse owner and globals.g.add((edodoc[str(did)], edodoc["owner"], edocol[str(pid)])) # ownership # Assign values globals.g.add((edodoc[str(did)], edodoc["name"], Literal(name))) # assign name globals.g.add((edodoc[str(did)], edodoc["content"], Literal(content))) # assign empty content # Write database globals.writedb() return did
def new(pid, name, content): """ pre: id, unique time post: a new page id is added to g. The user is added as owner and to the whitelist and a first version of the document is created. """ #Initialisation did = globals.newdid() # Create initial nodes globals.g.add((edodoc[str(did)], edodoc['type'], Literal("document"))) # Setting owner, reverse owner and globals.g.add((edodoc[str(did)], edodoc['owner'], edocol[str(pid)])) # ownership # Assign values globals.g.add((edodoc[str(did)], edodoc['name'], Literal(name) )) # assign name globals.g.add((edodoc[str(did)], edodoc['content'], Literal(content))) # assign empty content #Write database globals.writedb() return did
def getlastxgeneral(number): results = [] id = int(globals.newdid()) while (len(results) <> number): id = id - 1 if id < 0: break else: if (globals.g.query( """ SELECT ?p ?n WHERE { edodoc:%s ?p ?n . }""" % (id, ), initNs=globals.ns).serialize(format='python') == []): pass else: results = results + [str(id)] assert results <> [], 'No documents at all in this database' return results
def getlastxgeneral(number): results = [] id = int(globals.newdid()) while len(results) <> number: id = id - 1 if id < 0: break else: if ( globals.g.query( """ SELECT ?p ?n WHERE { edodoc:%s ?p ?n . }""" % (id,), initNs=globals.ns, ).serialize(format="python") == [] ): pass else: results = results + [str(id)] assert results <> [], "No documents at all in this database" return results