summaryrefslogtreecommitdiffstats
path: root/flatpages/views.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2021-03-24 15:46:35 +0000
committerPhilip Sargent <philip.sargent@klebos.com>2021-03-24 15:46:35 +0000
commit9a914873750cee6fb2cde17a45fcd7f7a487a796 (patch)
tree3c93df2cfdcd52b7501761be8c7273f749e052a1 /flatpages/views.py
parent7f37327bcdb3d6588a5ca189f7f0ecfba3f95ffa (diff)
downloadtroggle-9a914873750cee6fb2cde17a45fcd7f7a487a796.tar.gz
troggle-9a914873750cee6fb2cde17a45fcd7f7a487a796.tar.bz2
troggle-9a914873750cee6fb2cde17a45fcd7f7a487a796.zip
pathlib for path management & cavelist fixes
Diffstat (limited to 'flatpages/views.py')
-rw-r--r--flatpages/views.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/flatpages/views.py b/flatpages/views.py
index 518b157..aa1793d 100644
--- a/flatpages/views.py
+++ b/flatpages/views.py
@@ -1,5 +1,6 @@
import os
import re
+from pathlib import Path
from django.shortcuts import render, redirect
from django.http import HttpResponse, HttpResponseRedirect, Http404
@@ -52,15 +53,16 @@ def flatpage(request, path):
print(("flat path noinfo", path))
return HttpResponseRedirect(reverse("auth_login") + '?next=%s' % request.path)
+ expowebpath = Path(settings.EXPOWEB)
if path.endswith("/") or path == "":
#print(" - FLATPAGES the file: {} ENDSWITH ...".format(path))
try:
- o = open(os.path.normpath(settings.EXPOWEB + path + "index.html"), "rb")
+ o = open(os.path.normpath(expowebpath / path / "index.html"), "rb")
path = path + "index.html"
except IOError:
try:
- o = open(os.path.normpath(settings.EXPOWEB + path + "index.htm"), "rb")
+ o = open(os.path.normpath(expowebpath / path / "index.htm"), "rb")
path = path + "index.htm"
except IOError:
return render(request, 'pagenotfound.html', {'path': path})
@@ -77,8 +79,8 @@ def flatpage(request, path):
path = path.replace("static", settings.MEDIA_ROOT)
filetobeopened = os.path.normpath(path)
else:
- #print(" - NO _ROOT: {} ...".format(settings.EXPOWEB))
- filetobeopened = os.path.normpath(settings.EXPOWEB + path)
+ #print(" - NO _ROOT: {} ...".format(expowebpath))
+ filetobeopened = os.path.normpath(expowebpath / path)
#print(" - FLATPAGES full path : {} ...".format(filetobeopened))
o = open(filetobeopened, "rb")