comparison mercurial/hgweb/hgweb_mod.py @ 6777:44c5157474e7

hgweb: protocol requests are processed immediately This makes separation of interface/webcommands and protocol easier and will make http repos slightly faster because there's less overhead.
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Sat, 28 Jun 2008 15:28:43 +0200
parents 39319a457dda
children d3147b4e3e8a
comparison
equal deleted inserted replaced
6776:39319a457dda 6777:44c5157474e7
87 87
88 def run_wsgi(self, req): 88 def run_wsgi(self, req):
89 89
90 self.refresh() 90 self.refresh()
91 91
92 # process this if it's a protocol request
93 # protocol bits don't need to create any URLs
94 # and the clients always use the old URL structure
95
96 cmd = req.form.get('cmd', [''])[0]
97 if cmd and cmd in protocol.__all__:
98 method = getattr(protocol, cmd)
99 method(self, req)
100 return
101
92 # work with CGI variables to create coherent structure 102 # work with CGI variables to create coherent structure
93 # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME 103 # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME
94 104
95 req.url = req.env['SCRIPT_NAME'] 105 req.url = req.env['SCRIPT_NAME']
96 if not req.url.endswith('/'): 106 if not req.url.endswith('/'):
118 if style != -1: 128 if style != -1:
119 req.form['style'] = [cmd[:style]] 129 req.form['style'] = [cmd[:style]]
120 cmd = cmd[style+1:] 130 cmd = cmd[style+1:]
121 131
122 # avoid accepting e.g. style parameter as command 132 # avoid accepting e.g. style parameter as command
123 if hasattr(webcommands, cmd) or hasattr(protocol, cmd): 133 if hasattr(webcommands, cmd):
124 req.form['cmd'] = [cmd] 134 req.form['cmd'] = [cmd]
135 else:
136 cmd = ''
125 137
126 if args and args[0]: 138 if args and args[0]:
127 node = args.pop(0) 139 node = args.pop(0)
128 req.form['node'] = [node] 140 req.form['node'] = [node]
129 if args: 141 if args:
136 for type_, spec in self.archive_specs.iteritems(): 148 for type_, spec in self.archive_specs.iteritems():
137 ext = spec[2] 149 ext = spec[2]
138 if fn.endswith(ext): 150 if fn.endswith(ext):
139 req.form['node'] = [fn[:-len(ext)]] 151 req.form['node'] = [fn[:-len(ext)]]
140 req.form['type'] = [type_] 152 req.form['type'] = [type_]
141
142 # process this if it's a protocol request
143
144 cmd = req.form.get('cmd', [''])[0]
145 if cmd in protocol.__all__:
146 method = getattr(protocol, cmd)
147 method(self, req)
148 return
149 153
150 # process the web interface request 154 # process the web interface request
151 155
152 try: 156 try:
153 157