##// END OF EJS Templates
hgweb: add some documentation...
Gregory Szorc -
r26132:9df8c729 default
parent child Browse files
Show More
@@ -62,6 +62,16 b" def makebreadcrumb(url, prefix=''):"
62 62
63 63
64 64 class hgweb(object):
65 """HTTP server for individual repositories.
66
67 Instances of this class serve HTTP responses for a particular
68 repository.
69
70 Instances are typically used as WSGI applications.
71
72 Some servers are multi-threaded. On these servers, there may
73 be multiple active threads inside __call__.
74 """
65 75 def __init__(self, repo, name=None, baseui=None):
66 76 if isinstance(repo, str):
67 77 if baseui:
@@ -157,6 +167,11 b' class hgweb(object):'
157 167 self.repo.ui.environ = request.env
158 168
159 169 def run(self):
170 """Start a server from CGI environment.
171
172 Modern servers should be using WSGI and should avoid this
173 method, if possible.
174 """
160 175 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."):
161 176 raise RuntimeError("This function is only intended to be "
162 177 "called while running as a CGI script.")
@@ -164,11 +179,19 b' class hgweb(object):'
164 179 wsgicgi.launch(self)
165 180
166 181 def __call__(self, env, respond):
182 """Run the WSGI application.
183
184 This may be called by multiple threads.
185 """
167 186 req = wsgirequest(env, respond)
168 187 return self.run_wsgi(req)
169 188
170 189 def run_wsgi(self, req):
190 """Internal method to run the WSGI application.
171 191
192 This is typically only called by Mercurial. External consumers
193 should be using instances of this class as the WSGI application.
194 """
172 195 self.refresh(req)
173 196
174 197 # work with CGI variables to create coherent structure
@@ -79,6 +79,13 b' def geturlcgivars(baseurl, port):'
79 79 return name, str(port), path
80 80
81 81 class hgwebdir(object):
82 """HTTP server for multiple repositories.
83
84 Given a configuration, different repositories will be served depending
85 on the request path.
86
87 Instances are typically used as WSGI applications.
88 """
82 89 def __init__(self, conf, baseui=None):
83 90 self.conf = conf
84 91 self.baseui = baseui
@@ -40,6 +40,12 b' def normalize(form):'
40 40 return form
41 41
42 42 class wsgirequest(object):
43 """Higher-level API for a WSGI request.
44
45 WSGI applications are invoked with 2 arguments. They are used to
46 instantiate instances of this class, which provides higher-level APIs
47 for obtaining request parameters, writing HTTP output, etc.
48 """
43 49 def __init__(self, wsgienv, start_response):
44 50 version = wsgienv['wsgi.version']
45 51 if (version < (1, 0)) or (version >= (2, 0)):
General Comments 0
You need to be logged in to leave comments. Login now