Added an errorhandler for the configuration file
This commit is contained in:
parent
117a6de1d1
commit
7d50eb1e4b
58
blogthon.cgi
58
blogthon.cgi
@ -9,7 +9,7 @@
|
|||||||
# Author: Stefan Ritter <xeno@thehappy.de>
|
# Author: Stefan Ritter <xeno@thehappy.de>
|
||||||
# Description: A simple blogging software
|
# Description: A simple blogging software
|
||||||
|
|
||||||
import cgi, os, time, glob, re, md5
|
import cgi, os, time, glob, re, md5, sys
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
|
|
||||||
def generate_uuid(string):
|
def generate_uuid(string):
|
||||||
@ -22,25 +22,51 @@ def generate_uuid(string):
|
|||||||
string = string_md5sum_1 + '-' + string_md5sum_2 + '-' + string_md5sum_3 + '-' + string_md5sum_4 + '-' + string_md5sum_5
|
string = string_md5sum_1 + '-' + string_md5sum_2 + '-' + string_md5sum_3 + '-' + string_md5sum_4 + '-' + string_md5sum_5
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
def errorpage(string):
|
||||||
|
print 'Content-type: text/html\n'
|
||||||
|
print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'
|
||||||
|
print ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
|
||||||
|
print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">'
|
||||||
|
print '<head>'
|
||||||
|
print ' <title>Error!</title>'
|
||||||
|
print '</head>'
|
||||||
|
print '<body>'
|
||||||
|
print ' <b>' + string + '</b> is not set in configuration, please check your installation!'
|
||||||
|
print '</body>'
|
||||||
|
print '</html>'
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
# Read configuration. TODO: a human readable errorhandler
|
|
||||||
configuration = ConfigParser.ConfigParser()
|
configuration = ConfigParser.ConfigParser()
|
||||||
configuration.read('configuration')
|
configuration.read('configuration')
|
||||||
|
|
||||||
blog_title = configuration.get('personal', 'blog_title')
|
try: blog_title = configuration.get('personal', 'blog_title')
|
||||||
blog_url = configuration.get('personal', 'blog_url')
|
except: errorpage("blog_title")
|
||||||
keywords = configuration.get('personal', 'keywords')
|
try: blog_url = configuration.get('personal', 'blog_url')
|
||||||
entries_dir = configuration.get('personal', 'entries_dir')
|
except: errorpage("blog_url")
|
||||||
entries_suffix = configuration.get('personal', 'entries_suffix')
|
try: keywords = configuration.get('personal', 'keywords')
|
||||||
staticpages_dir = configuration.get('personal', 'staticpages_dir')
|
except: errorpage("keywords")
|
||||||
style = configuration.get('look', 'style')
|
try: entries_dir = configuration.get('personal', 'entries_dir')
|
||||||
entries_per_page = configuration.getint('look', 'entries_per_page')
|
except: errorpage("entries_dir")
|
||||||
monthlist = configuration.get('look', 'monthlist')
|
try: entries_suffix = configuration.get('personal', 'entries_suffix')
|
||||||
staticpages = configuration.get('look', 'staticpages')
|
except: errorpage("entries_suffix")
|
||||||
linklist = configuration.get('look', 'linklist')
|
try: staticpages_dir = configuration.get('personal', 'staticpages_dir')
|
||||||
permalinks = configuration.get('look', 'permalinks')
|
except: errorpage("staticpages_dir")
|
||||||
comments = configuration.get('look', 'comments')
|
try: style = configuration.get('look', 'style')
|
||||||
newest_first = configuration.get('look', 'newest_first')
|
except: errorpage("style")
|
||||||
|
try: entries_per_page = configuration.getint('look', 'entries_per_page')
|
||||||
|
except: errorpage("entries_per_page")
|
||||||
|
try: monthlist = configuration.get('look', 'monthlist')
|
||||||
|
except: errorpage("monthlist")
|
||||||
|
try: staticpages = configuration.get('look', 'staticpages')
|
||||||
|
except: errorpage("staticpages")
|
||||||
|
try: linklist = configuration.get('look', 'linklist')
|
||||||
|
except: errorpage("linklist")
|
||||||
|
try: permalinks = configuration.get('look', 'permalinks')
|
||||||
|
except: errorpage("permalinks")
|
||||||
|
try: comments = configuration.get('look', 'comments')
|
||||||
|
except: errorpage("comments")
|
||||||
|
try: newest_first = configuration.get('look', 'newest_first')
|
||||||
|
except: errorpage("newest_first")
|
||||||
|
|
||||||
# Read POST Variables
|
# Read POST Variables
|
||||||
action = cgi.FieldStorage()
|
action = cgi.FieldStorage()
|
||||||
|
Loading…
Reference in New Issue
Block a user