~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/http_smart_server.txt

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-12-18 17:35:33 UTC
  • mfrom: (2190.1.7 bzr_http_fixes)
  • Revision ID: pqm@pqm.ubuntu.com-20061218173533-46a6cb3b1d08b8ab
(John Arbash Meinel) Implement bzr+http:// and update docs to indicate how to set it up.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        Options Indexes, FollowSymLinks
49
49
        RewriteEngine On
50
50
        RewriteBase /code
51
 
        RewriteRule ^(.*)/\.bzr/smart$ /srv/example.com/scripts/bzr-smart.fcgi
 
51
        RewriteRule ^(.*/|)\.bzr/smart$ /srv/example.com/scripts/bzr-smart.fcgi
52
52
    </Directory>
53
53
    
54
54
    # bzr-smart.fcgi isn't under the DocumentRoot, so Alias it into the URL
81
81
Define the rewrite rules with mod_rewrite the same way as for FastCGI, except
82
82
change::
83
83
 
84
 
    RewriteRule ^(.*)/\.bzr/smart$ /srv/example.com/scripts/bzr-smart.fcgi
 
84
    RewriteRule ^(.*/|)\.bzr/smart$ /srv/example.com/scripts/bzr-smart.fcgi
85
85
 
86
86
to::
87
87
 
88
 
    RewriteRule ^(.*)/\.bzr/smart$ /srv/example.com/scripts/bzr-smart.py
 
88
    RewriteRule ^(.*/|)\.bzr/smart$ /srv/example.com/scripts/bzr-smart.py
89
89
 
90
90
Like with mod_fastcgi, we also define how our script is to be handled::
91
91
 
94
94
        <Files bzr-smart.py>
95
95
            PythonPath "sys.path+['/srv/example.com/scripts']"
96
96
            AddHandler python-program .py
97
 
            PythonHandler bzr-smart
 
97
            PythonHandler bzr-smart::handler
98
98
        </Files>
99
99
    </Directory>
100
100
 
123
123
    smart_server_app = wsgi.make_app(
124
124
        root='/srv/example.com/code',
125
125
        prefix='/code/',
126
 
        path_var='REQUEST_URI')
 
126
        path_var='REQUEST_URI',
 
127
        readonly=True)
127
128
 
128
129
    fcgi.WSGIServer(smart_server_app).run()
129
130
        
146
147
    smart_server_app = wsgi.make_app(
147
148
        root='/srv/example.com/code',
148
149
        prefix='/code/',
149
 
        path_var='REQUEST_URI')
 
150
        path_var='REQUEST_URI',
 
151
        readonly=True)
150
152
 
151
 
    modpywsgi.WSGIServer(smart_server_app).run()
 
153
    def handler(request):
 
154
        """Handle a single request."""
 
155
        wsgi_server = modpywsgi.WSGIServer(smart_server_app)
 
156
        return wsgi_server.run(request)
152
157
        
153
158
The `modpywsgi` module can be found at http://trac.pocoo.org/wiki/ModPyWsgi.  It
154
159
is part of pocoo_.
193
198
 
194
199
.. _WSGI standard: http://www.python.org/dev/peps/pep-0333/
195
200
 
 
201
 
 
202
Pushing over ``bzr+http://``
 
203
----------------------------
 
204
 
 
205
It is possible to allow pushing data over the http smart server. The
 
206
easiest way to do this, is to just supply ``readonly=False`` to the
 
207
``wsgi.make_app()`` call. But be careful, because the smart protocol does
 
208
not contain any Authentication. So if you enable write support, you will
 
209
want to restrict access to ``.bzr/smart`` URLs to restrict who can
 
210
actually write data on your system.  At this time, it is not possible to
 
211
allow some people to have read-only access and others to have read-write
 
212
access to the same urls. Because at the HTTP layer (which is doing the
 
213
Authenticating), everything is just a POST request.  However, it would
 
214
certainly be possible to have HTTPS require authentication and use a
 
215
writable server, and plain HTTP allow read-only access.
 
216
 
 
217
 
 
218
.. 
 
219
   vim: ft=rst tw=74 et