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