removed main.cfg, not used anywhere
[limo.git] / settings.py
blobea8dd5ec051ff6f5ad6858dec3a3f55a8d501cda
1 import re, sys
3 class Settings:
4 tempDir = r"c:\temp" if sys.platform == "win32" else "/tmp"
6 # where to listen for incoming fastcgi requests
7 # ex. ('localhost',XXXX) will listen on tcp port XXXX
8 # a filesystem path will try to listen on a UNIX Socket
9 # ex. /tmp/limo.sock
10 defaultSocket = ('localhost',7143)
12 baseUrl = "http://localhost"
14 allowedServerNames = ('localhost','192.168.1.101',)
16 # the directory to store the cache (for compressed pages, processed images, etc.)
17 # - this will see a LOT of activity so put it somewhere fast
18 # - it can be relative to the location of limo.py, or absolute
19 # - should not end in a "/"
20 cacheDir = "cache"
22 # minutes before session cookies expire
23 sessionTimeout = 90
25 # should the final html be prettify'd by BeautifulSoup (implies bufferOutput)
26 prettifyHTML = True
28 # will collapse all output to a single write
29 bufferOutput = True
31 # enabling Etags support
32 supportEtags = True
34 # if enabled, requests to urls that lack a trailing slash will be redirected to a url that includes a trailing slash.
35 # http://localhost/foo -> http://localhost/foo/
36 # the app server sees no difference between the two URLS, but browsers generate relative URLs differently for each.
37 strictScriptNameRedirects = True
39 # log all the incoming request headers
40 logRequestHeaders = False
42 # log all outgoing response headers
43 logResponseHeaders = False
45 # log the start times of each request
46 logRequestStartTime = True
48 # logs what the load on the server is at the time of each request
49 logRequestLoad = True
51 # log the regions that render each page
52 logRequestRegions = False
54 # log what kind of compression is used for each request
55 logCompression = False
57 # VERY VERBOSE: logs every fastcgi packet in and out
58 logAllRequestTraffic = False
60 # log the session token passed for each request
61 logSessionToken = True
63 # show verbose 404 messages, including the real error
64 showVerbose404 = True
66 # logs messages like: Theme[default] => templates/block.tpl => theme/default/templates/block.tpl
67 # to let you know where files are coming from
68 debugThemes = False
70 # dumps a text sitemap to the log as the server starts up
71 debugSitemap = True
73 # log messages when each module is loaded successfully (errors are always logged)
74 logModuleLoading = False
76 # whether to profile anything at all
77 # if set to False, all calls to profile() will return None
78 # if true, every second call to profile('foo') returns the ms elapsed since the first call to profile('foo')
79 profileServer = True
80 # should profile results be logged to the log file
81 profileLogOutput = False
82 # will write every query in a request to the log file
83 profileLogQueries = False
84 # if the current session has profile privileges, output profile data in html
85 profileHTMLOutput = False
87 # if a theme cannot find a request file:
88 abortOnMissingFile = False # raises 404 if some template is missing for that page
89 warnOnMissingFile = True# print a message in the log when this happens
90 # NOTE: the page will render anyway, but with some content missing
92 # detect if a session token is used on one machine, and moved to another
93 # causes an extra query for every session load
94 detectSessionHijack = False
96 disableAllLogging = False
98 compressPerUserAgent = (
99 ("iPhone OS", "gzip"),
100 ("Android", "gzip"),
101 (".*", "gzip"),
103 @staticmethod
104 def getCompression(UserAgent):
105 for k,v in Settings.compressPerUserAgent:
106 if re.search(k, UserAgent) is not None:
107 return v
108 return None
110 # controls a few things:
111 # - should tests be loaded at server start?
112 developmentMode = True
114 def _true(value):
115 if value in (True,False,): # if they were actual boolean types already
116 return value
117 # otherwise only deal with strings
118 assert type(value) == str
119 # trim the strings
120 while value[0] == ' ':
121 value = value[1:]
122 while value[-1] == ' ':
123 value = value[:-1]
124 value = value.lower()
125 return (value == '1' or value == 'true')