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>
|
||||
# Description: A simple blogging software
|
||||
|
||||
import cgi, os, time, glob, re, md5
|
||||
import cgi, os, time, glob, re, md5, sys
|
||||
import ConfigParser
|
||||
|
||||
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
|
||||
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.read('configuration')
|
||||
|
||||
blog_title = configuration.get('personal', 'blog_title')
|
||||
blog_url = configuration.get('personal', 'blog_url')
|
||||
keywords = configuration.get('personal', 'keywords')
|
||||
entries_dir = configuration.get('personal', 'entries_dir')
|
||||
entries_suffix = configuration.get('personal', 'entries_suffix')
|
||||
staticpages_dir = configuration.get('personal', 'staticpages_dir')
|
||||
style = configuration.get('look', 'style')
|
||||
entries_per_page = configuration.getint('look', 'entries_per_page')
|
||||
monthlist = configuration.get('look', 'monthlist')
|
||||
staticpages = configuration.get('look', 'staticpages')
|
||||
linklist = configuration.get('look', 'linklist')
|
||||
permalinks = configuration.get('look', 'permalinks')
|
||||
comments = configuration.get('look', 'comments')
|
||||
newest_first = configuration.get('look', 'newest_first')
|
||||
try: blog_title = configuration.get('personal', 'blog_title')
|
||||
except: errorpage("blog_title")
|
||||
try: blog_url = configuration.get('personal', 'blog_url')
|
||||
except: errorpage("blog_url")
|
||||
try: keywords = configuration.get('personal', 'keywords')
|
||||
except: errorpage("keywords")
|
||||
try: entries_dir = configuration.get('personal', 'entries_dir')
|
||||
except: errorpage("entries_dir")
|
||||
try: entries_suffix = configuration.get('personal', 'entries_suffix')
|
||||
except: errorpage("entries_suffix")
|
||||
try: staticpages_dir = configuration.get('personal', 'staticpages_dir')
|
||||
except: errorpage("staticpages_dir")
|
||||
try: style = configuration.get('look', 'style')
|
||||
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
|
||||
action = cgi.FieldStorage()
|
||||
|
Loading…
Reference in New Issue
Block a user