##// 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 72 object.__setattr__(self, 'app', app)
73 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 86 # Proxy unknown reads and writes to the application instance
76 87 # until everything is moved to us.
77 88 def __getattr__(self, name):
@@ -80,6 +91,24 b' class requestcontext(object):'
80 91 def __setattr__(self, name, value):
81 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 112 class hgweb(object):
84 113 """HTTP server for individual repositories.
85 114
@@ -117,7 +146,6 b' class hgweb(object):'
117 146 self.mtime = -1
118 147 self.reponame = name
119 148 self.archives = 'zip', 'gz', 'bz2'
120 self.stripecount = 1
121 149 # a repo owner may set web.templates in .hg/hgrc to get any file
122 150 # readable by the user running the CGI script
123 151 self.templatepath = self.config('web', 'templates')
@@ -170,12 +198,6 b' class hgweb(object):'
170 198 if repostate != self.repostate:
171 199 r = hg.repository(self.repo.baseui, self.repo.url())
172 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 201 encoding.encoding = self.config("web", "encoding",
180 202 encoding.encoding)
181 203 # update these last to avoid threads seeing empty settings
General Comments 0
You need to be logged in to leave comments. Login now