##// END OF EJS Templates
hgweb: remove proxy to hgweb instance...
Gregory Szorc -
r26217:0d0a0837 default
parent child Browse files
Show More
@@ -67,45 +67,29 b' class requestcontext(object):'
67 mutable and race-free state for requests.
67 mutable and race-free state for requests.
68 """
68 """
69 def __init__(self, app):
69 def __init__(self, app):
70 object.__setattr__(self, 'app', app)
70 self.repo = app.repo
71 object.__setattr__(self, 'repo', app.repo)
71 self.reponame = app.reponame
72 object.__setattr__(self, 'reponame', app.reponame)
73
72
74 object.__setattr__(self, 'archives', ('zip', 'gz', 'bz2'))
73 self.archives = ('zip', 'gz', 'bz2')
75
74
76 object.__setattr__(self, 'maxchanges',
75 self.maxchanges = self.configint('web', 'maxchanges', 10)
77 self.configint('web', 'maxchanges', 10))
76 self.stripecount = self.configint('web', 'stripes', 1)
78 object.__setattr__(self, 'stripecount',
77 self.maxshortchanges = self.configint('web', 'maxshortchanges', 60)
79 self.configint('web', 'stripes', 1))
78 self.maxfiles = self.configint('web', 'maxfiles', 10)
80 object.__setattr__(self, 'maxshortchanges',
79 self.allowpull = self.configbool('web', 'allowpull', True)
81 self.configint('web', 'maxshortchanges', 60))
82 object.__setattr__(self, 'maxfiles',
83 self.configint('web', 'maxfiles', 10))
84 object.__setattr__(self, 'allowpull',
85 self.configbool('web', 'allowpull', True))
86
80
87 # we use untrusted=False to prevent a repo owner from using
81 # we use untrusted=False to prevent a repo owner from using
88 # web.templates in .hg/hgrc to get access to any file readable
82 # web.templates in .hg/hgrc to get access to any file readable
89 # by the user running the CGI script
83 # by the user running the CGI script
90 object.__setattr__(self, 'templatepath',
84 self.templatepath = self.config('web', 'templates', untrusted=False)
91 self.config('web', 'templates', untrusted=False))
92
85
93 # This object is more expensive to build than simple config values.
86 # This object is more expensive to build than simple config values.
94 # It is shared across requests. The app will replace the object
87 # It is shared across requests. The app will replace the object
95 # if it is updated. Since this is a reference and nothing should
88 # if it is updated. Since this is a reference and nothing should
96 # modify the underlying object, it should be constant for the lifetime
89 # modify the underlying object, it should be constant for the lifetime
97 # of the request.
90 # of the request.
98 object.__setattr__(self, 'websubtable', app.websubtable)
91 self.websubtable = app.websubtable
99
92
100 # Proxy unknown reads and writes to the application instance
101 # until everything is moved to us.
102 def __getattr__(self, name):
103 return getattr(self.app, name)
104
105 def __setattr__(self, name, value):
106 return setattr(self.app, name, value)
107
108 # Servers are often run by a user different from the repo owner.
109 # Trust the settings from the .hg/hgrc files by default.
93 # Trust the settings from the .hg/hgrc files by default.
110 def config(self, section, name, default=None, untrusted=True):
94 def config(self, section, name, default=None, untrusted=True):
111 return self.repo.ui.config(section, name, default,
95 return self.repo.ui.config(section, name, default,
@@ -177,10 +161,9 b' class requestcontext(object):'
177 sessionvars = webutil.sessionvars(vars, start)
161 sessionvars = webutil.sessionvars(vars, start)
178
162
179 if not self.reponame:
163 if not self.reponame:
180 object.__setattr__(self, 'reponame',
164 self.reponame = (self.config('web', 'name')
181 (self.config('web', 'name')
165 or req.env.get('REPO_NAME')
182 or req.env.get('REPO_NAME')
166 or req.url.strip('/') or self.repo.root)
183 or req.url.strip('/') or self.repo.root))
184
167
185 def websubfilter(text):
168 def websubfilter(text):
186 return websub(text, self.websubtable)
169 return websub(text, self.websubtable)
@@ -398,8 +381,7 b' class hgweb(object):'
398 msg = 'no such method: %s' % cmd
381 msg = 'no such method: %s' % cmd
399 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
382 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
400 elif cmd == 'file' and 'raw' in req.form.get('style', []):
383 elif cmd == 'file' and 'raw' in req.form.get('style', []):
401 # TODO convert to regular assignment once app proxy is removed.
384 rctx.ctype = ctype
402 object.__setattr__(rctx, 'ctype', ctype)
403 content = webcommands.rawfile(rctx, req, tmpl)
385 content = webcommands.rawfile(rctx, req, tmpl)
404 else:
386 else:
405 content = getattr(webcommands, cmd)(rctx, req, tmpl)
387 content = getattr(webcommands, cmd)(rctx, req, tmpl)
General Comments 0
You need to be logged in to leave comments. Login now