acn/rtx
acn
/
rtx
1
0
Fork 0

Mehrere Verzeichnisse für Seiten ermöglicht

This commit is contained in:
acn 2016-10-31 16:40:10 +01:00
parent 1968449c69
commit 13c2cbe34f
2 changed files with 14 additions and 12 deletions

View File

@ -6,9 +6,11 @@ Configuration file
import logging import logging
## general settings: ## define the location of rtx pages
PAGES="pages/" ## rtx searches all directories and serves the page from the first one (lowest index)
DEMOPAGES="demopages/" PAGES[0]="pages/"
PAGES[1]="presentation/"
PAGES[2]="demopages/"
## logging settings: ## logging settings:
# loglevel values: DEBUG (all messages) > INFO > WARNING > ERROR > CRITICAL (only cricital messages) # loglevel values: DEBUG (all messages) > INFO > WARNING > ERROR > CRITICAL (only cricital messages)

View File

@ -35,12 +35,10 @@ class rtxPage:
@staticmethod @staticmethod
def exists(page): def exists(page):
""" checks if the page (i.e. the file) exists """ """ checks if the page (i.e. the file) exists """
if os.path.isfile(config.PAGES + page): for path in config.PAGES:
if os.path.isfile(path + page):
return True return True
elif os.path.isfile(config.DEMOPAGES + page): return False
return True
else:
return False
def get_page(self): def get_page(self):
""" returns the page if loaded """ returns the page if loaded
@ -78,11 +76,13 @@ class rtxPage:
returns False if the page cannot be found returns False if the page cannot be found
returns True if the page has been loaded returns True if the page has been loaded
""" """
if os.path.isfile(config.PAGES + page): for path in config.PAGES:
filename = config.PAGES + page if os.path.isfile(path + page):
elif os.path.isfile(config.DEMOPAGES + page): filename = path + page
filename = config.DEMOPAGES + page """ page has been found, now exit the for loop """
break
else: else:
""" page does not exist anywhere, so exit the function """
return False return False
with open(filename, "rb") as f: with open(filename, "rb") as f: