##// END OF EJS Templates
hgweb: move some config options to requestcontext...
Gregory Szorc -
r26135:edfb4d3b default
parent child Browse files
Show More
@@ -72,6 +72,17 b' class requestcontext(object):'
72 object.__setattr__(self, 'app', app)
72 object.__setattr__(self, 'app', app)
73 object.__setattr__(self, 'repo', app.repo)
73 object.__setattr__(self, 'repo', app.repo)
74
74
75 object.__setattr__(self, 'maxchanges',
76 self.configint('web', 'maxchanges', 10))
77 object.__setattr__(self, 'stripecount',
78 self.configint('web', 'stripes', 1))
79 object.__setattr__(self, 'maxshortchanges',
80 self.configint('web', 'maxshortchanges', 60))
81 object.__setattr__(self, 'maxfiles',
82 self.configint('web', 'maxfiles', 10))
83 object.__setattr__(self, 'allowpull',
84 self.configbool('web', 'allowpull', True))
85
75 # Proxy unknown reads and writes to the application instance
86 # Proxy unknown reads and writes to the application instance
76 # until everything is moved to us.
87 # until everything is moved to us.
77 def __getattr__(self, name):
88 def __getattr__(self, name):
@@ -80,6 +91,24 b' class requestcontext(object):'
80 def __setattr__(self, name, value):
91 def __setattr__(self, name, value):
81 return setattr(self.app, name, value)
92 return setattr(self.app, name, value)
82
93
94 # Servers are often run by a user different from the repo owner.
95 # Trust the settings from the .hg/hgrc files by default.
96 def config(self, section, name, default=None, untrusted=True):
97 return self.repo.ui.config(section, name, default,
98 untrusted=untrusted)
99
100 def configbool(self, section, name, default=False, untrusted=True):
101 return self.repo.ui.configbool(section, name, default,
102 untrusted=untrusted)
103
104 def configint(self, section, name, default=None, untrusted=True):
105 return self.repo.ui.configint(section, name, default,
106 untrusted=untrusted)
107
108 def configlist(self, section, name, default=None, untrusted=True):
109 return self.repo.ui.configlist(section, name, default,
110 untrusted=untrusted)
111
83 class hgweb(object):
112 class hgweb(object):
84 """HTTP server for individual repositories.
113 """HTTP server for individual repositories.
85
114
@@ -117,7 +146,6 b' class hgweb(object):'
117 self.mtime = -1
146 self.mtime = -1
118 self.reponame = name
147 self.reponame = name
119 self.archives = 'zip', 'gz', 'bz2'
148 self.archives = 'zip', 'gz', 'bz2'
120 self.stripecount = 1
121 # a repo owner may set web.templates in .hg/hgrc to get any file
149 # a repo owner may set web.templates in .hg/hgrc to get any file
122 # readable by the user running the CGI script
150 # readable by the user running the CGI script
123 self.templatepath = self.config('web', 'templates')
151 self.templatepath = self.config('web', 'templates')
@@ -170,12 +198,6 b' class hgweb(object):'
170 if repostate != self.repostate:
198 if repostate != self.repostate:
171 r = hg.repository(self.repo.baseui, self.repo.url())
199 r = hg.repository(self.repo.baseui, self.repo.url())
172 self.repo = self._getview(r)
200 self.repo = self._getview(r)
173 self.maxchanges = int(self.config("web", "maxchanges", 10))
174 self.stripecount = int(self.config("web", "stripes", 1))
175 self.maxshortchanges = int(self.config("web", "maxshortchanges",
176 60))
177 self.maxfiles = int(self.config("web", "maxfiles", 10))
178 self.allowpull = self.configbool("web", "allowpull", True)
179 encoding.encoding = self.config("web", "encoding",
201 encoding.encoding = self.config("web", "encoding",
180 encoding.encoding)
202 encoding.encoding)
181 # update these last to avoid threads seeing empty settings
203 # update these last to avoid threads seeing empty settings
General Comments 0
You need to be logged in to leave comments. Login now