Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN chmod +x /start.sh
# Template config
ENV APP_ENTRYPOINT web
ENV LOG_LEVEL info
ENV LOG_SPARQL_ALL True
ENV MU_SPARQL_ENDPOINT 'http://database:8890/sparql'
ENV MU_SPARQL_UPDATEPOINT 'http://database:8890/sparql'
ENV MU_APPLICATION_GRAPH 'http://mu.semte.ch/application'
Expand Down
7 changes: 6 additions & 1 deletion helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
consoleHandler = logging.StreamHandler(stream=sys.stdout)# or stderr?
logger.addHandler(consoleHandler)

LOG_SPARQL_ALL = os.environ.get('LOG_SPARQL_ALL') in ('TRUE', 'True', 'true')

def generate_uuid():
"""Generates a random unique user id (UUID) based on the host ID and current time"""
return str(uuid.uuid1())
Expand Down Expand Up @@ -119,14 +121,15 @@ def validate_resource_type(expected_type, data):

def query(the_query):
"""Execute the given SPARQL query (select/ask/construct) on the triplestore and returns the results in the given return Format (JSON by default)."""
log("execute query: \n" + the_query)
for header in MU_HEADERS:
if header in request.headers:
sparqlQuery.customHttpHeaders[header] = request.headers[header]
else: # Make sure headers used for a previous query are cleared
if header in sparqlQuery.customHttpHeaders:
del sparqlQuery.customHttpHeaders[header]
sparqlQuery.setQuery(the_query)
if LOG_SPARQL_ALL:
log("execute query: \n" + the_query)
return sparqlQuery.query().convert()


Expand All @@ -140,6 +143,8 @@ def update(the_query):
del sparqlUpdate.customHttpHeaders[header]
sparqlUpdate.setQuery(the_query)
if sparqlUpdate.isSparqlUpdateRequest():
if LOG_SPARQL_ALL:
log("execute query: \n" + the_query)
sparqlUpdate.query()


Expand Down