Quellcode durchsuchen

Further simplify set operations.

Stefano Cossu vor 7 Jahren
Ursprung
Commit
05975332b6
3 geänderte Dateien mit 18 neuen und 13 gelöschten Zeilen
  1. 0 1
      lakesuperior/model/ldpr.py
  2. 13 11
      lakesuperior/store_layouts/rdf/simple_layout.py
  3. 5 1
      server.py

+ 0 - 1
lakesuperior/model/ldpr.py

@@ -66,7 +66,6 @@ def must_not_exist(fn):
 
 
 
-
 class Ldpr(metaclass=ABCMeta):
     '''LDPR (LDP Resource).
 

+ 13 - 11
lakesuperior/store_layouts/rdf/simple_layout.py

@@ -58,11 +58,10 @@ class SimpleLayout(BaseRdfLayout):
         try:
             qres = self.query(q)
         except ResultException:
-            # RDFlib bug? https://github.com/RDFLib/rdflib/issues/775
+            # RDFlib bug: https://github.com/RDFLib/rdflib/issues/775
             g = Graph()
         else:
             g = qres.graph
-            rsrc = Resource(g, uri)
             if not incl_srv_mgd:
                 self._logger.info('Removing server managed triples.')
                 for p in srv_mgd_predicates:
@@ -72,7 +71,7 @@ class SimpleLayout(BaseRdfLayout):
                     self._logger.debug('Removing type: {}'.format(t))
                     rsrc.remove(RDF.type, t)
 
-            return rsrc
+        return Resource(g, uri)
 
 
     def ask_rsrc_exists(self, uri=None):
@@ -85,7 +84,7 @@ class SimpleLayout(BaseRdfLayout):
             else:
                 return False
 
-        self._logger.info('Searching for resource: {}'.format(uri))
+        self._logger.info('Checking if resource exists: {}'.format(uri))
         return (uri, Variable('p'), Variable('o')) in self.ds
 
 
@@ -115,22 +114,25 @@ class SimpleLayout(BaseRdfLayout):
         # Delete the stored triples.
         self.delete_rsrc()
 
-        for s, p, o in imr.graph:
-            self.ds.add((s, p, o))
+        self.ds |= imr.graph
+        #for s, p, o in imr.graph:
+        #    self.ds.add((s, p, o))
 
         return self.RES_UPDATED
 
 
     @needs_rsrc
-    def modify_rsrc(self, remove, add):
+    def modify_rsrc(self, remove_trp, add_trp):
         '''
         See base_rdf_layout.update_rsrc.
         '''
-        for t in remove.predicate_objects():
-            self.rsrc.remove(t[0], t[1])
+        self.ds -= remove_trp
+        self.ds += add_trp
+        #for t in remove.predicate_objects():
+        #    self.rsrc.remove(t[0], t[1])
 
-        for t in add.predicate_objects():
-            self.rsrc.add(t[0], t[1])
+        #for t in add.predicate_objects():
+        #    self.rsrc.add(t[0], t[1])
 
 
     def delete_rsrc(self, inbound=True):

+ 5 - 1
server.py

@@ -1,3 +1,6 @@
+import logging
+import os
+
 from logging.config import dictConfig
 
 from flask import Flask, render_template
@@ -6,11 +9,12 @@ from lakesuperior.config_parser import config
 from lakesuperior.endpoints.ldp import ldp
 from lakesuperior.endpoints.query import query
 
-
 fcrepo = Flask(__name__)
 fcrepo.config.update(config['flask'])
 
 dictConfig(config['logging'])
+logger = logging.getLogger(__name__)
+logger.info('Starting LAKEsuperior HTTP server.')
 
 ## Configure enpoint blueprints here. ##