Prevent modification of auto generated files

This commit is contained in:
expo 2012-08-06 12:56:20 +02:00
parent 44eb3c0caf
commit 70a743f88b

View File

@ -107,6 +107,9 @@ def editflatpage(request, path):
filepath = os.path.normpath(settings.EXPOWEB + path) filepath = os.path.normpath(settings.EXPOWEB + path)
o = open(filepath, "r") o = open(filepath, "r")
html = o.read() html = o.read()
autogeneratedmatch = re.search(r"\<\!--\s*(.*?(Do not edit|auto-generated).*?)\s*--\>", html, re.DOTALL + re.IGNORECASE)
if autogeneratedmatch:
return HttpResponse(autogeneratedmatch.group(1))
m = re.search(r"(.*)<head([^>]*)>(.*)</head>(.*)<body([^>]*)>(.*)</body>(.*)", html, re.DOTALL + re.IGNORECASE) m = re.search(r"(.*)<head([^>]*)>(.*)</head>(.*)<body([^>]*)>(.*)</body>(.*)", html, re.DOTALL + re.IGNORECASE)
if m: if m:
filefound = True filefound = True