130 | | === Fix a few things === |
131 | | |
132 | | 23. Rename and fix CGI |
133 | | |
134 | | In wtrac.py add the line [import os;os.environ['TRAC_ENV'] = 'F:\\tracsvn\\trac.db'] to the first try block as shown here: |
135 | | {{{ |
136 | | try: |
137 | | import os;os.environ['TRAC_ENV'] = 'F:\\tracsvn\\trac.db' |
138 | | import trac.core |
139 | | trac.core.cgi_start() |
140 | | }}} |
141 | | You will still need the except block that follow the original |
142 | | |
143 | | The TRAC_ENV line is important as IIS6 won't pass this environment variable to the script when it runs. |
144 | | |
145 | | 23a. Fix core.py |
146 | | In F:\Python23\Lib\site-packages\trac\web\cgi_frontend.py: class CGIRequest, change the real_cgi_start function where it says |
147 | | {{{ |
148 | | path_info = os.getenv('PATH_INFO') |
149 | | }}} |
| 131 | === Modify a few Python scripts to cater for peculiarities specific to IIS === |
| 132 | |
| 133 | 22. Fix the CGI |
| 134 | |
| 135 | In [F:\Python23\Share\Trac\cgi-bin\trac.cgi] |
| 136 | modify the section between the try/except block to be as follows: |
| 137 | {{{ |
| 138 | try: |
| 139 | from trac.web import cgi_frontend |
| 140 | # PATCH IIS6 - start |
| 141 | import os |
| 142 | os.environ['TRAC_ENV'] = 'F:\\tracsvn\\Trac.db' |
| 143 | # PATCH IIS6 - end |
| 144 | cgi_frontend.run() |
| 145 | except Exception, e: |
| 146 | }}} |
| 147 | |
| 148 | The TRAC_ENV line is important as IIS6 won't pass this environment variable to the script when it runs. |
| 149 | |
| 150 | 23. Fix Python file - api.py |
| 151 | |
| 152 | In [F:\Python23\Lib\site-packages\trac\web\api.py], in the [redirect] function on the Request class, replace the entire function with: |
| 153 | {{{ |
| 154 | def redirect(self, url): |
| 155 | """Send a redirect to the client, forwarding to the specified URL. The |
| 156 | `url` may be relative or absolute, relative URLs will be translated |
| 157 | appropriately. |
| 158 | """ |
| 159 | base_url = '%s://%s' % ("http", os.getenv('SERVER_NAME')) |
| 160 | if self.session: |
| 161 | self.session.save() # has to be done before the redirect is sent |
| 162 | self.send_response(302) |
| 163 | if not url.startswith('http://') and not url.startswith('https://'): |
| 164 | # Make sure the URL is absolute |
| 165 | url = absolute_url(self, url) |
| 166 | self.send_header('Location', base_url + url) |
| 167 | self.send_header('Content-Type', 'text/plain') |
| 168 | self.send_header('Pragma', 'no-cache') |
| 169 | self.send_header('Cache-control', 'no-cache') |
| 170 | self.send_header('Expires', 'Fri, 01 Jan 1999 00:00:00 GMT') |
| 171 | self._send_cookie_headers() |
| 172 | self.end_headers() |
| 173 | |
| 174 | if self.method != 'HEAD': |
| 175 | self.write('Redirecting...') |
| 176 | |
| 177 | raise RequestDone |
| 178 | }}} |
| 179 | |
| 180 | |
| 181 | 24. Fix Python file - cgi_frontend.py |
| 182 | |
| 183 | In [F:\Python23\Lib\site-packages\trac\web\cgi_frontend.py], class CGIRequest, change the real_cgi_start function where it says : |
| 184 | {{{ |
| 185 | self.path_info = self.__environ.get('PATH_INFO', '') |
| 186 | }}} |
| 187 | |
152 | | path_info = os.getenv('PATH_INFO').replace(os.getenv('SCRIPT_NAME'),"") |
153 | | }}} |
154 | | |
155 | | In the redirect function on the Request class (in trac 0.9 it's in web\api.py), change the first part of the method to read: |
156 | | {{{ |
157 | | def redirect(self, url): |
158 | | base_url = '%s://%s' % ("http", os.getenv('SERVER_NAME')) |
159 | | self.send_response(302) |
160 | | self.send_header('Location', base_url + url) |
| 190 | |
| 191 | # IIS 6 Change |
| 192 | self.path_info = self.__environ.get('PATH_INFO', '') |
| 193 | self.path_info = self.path_info.replace(os.getenv('SCRIPT_NAME'),"") |
| 194 | # End IIS 6 Change |
| 195 | |