| 148 | | def tracChild(self, request, segments): |
|---|
| 149 | | """ |
|---|
| 150 | | Returns a resource within a trac project path. If a file is available |
|---|
| 151 | | in a corresponding path from the subdirectory 'trac', a static file |
|---|
| 152 | | resource to it is returned instead of a TracResource. |
|---|
| 153 | | """ |
|---|
| 154 | | subSegments = segments[1:] |
|---|
| 155 | | staticPath = ospath.join(self.vhostPath, 'trac', *subSegments) |
|---|
| 156 | | if len(subSegments) > 1 and ospath.exists(staticPath): |
|---|
| 157 | | return static.File(staticPath), () |
|---|
| 158 | | return self.tr, subSegments |
|---|
| 159 | | |
|---|
| | 166 | |
|---|
| | 167 | def tracChild(self, request, segments): |
|---|
| | 168 | """ |
|---|
| | 169 | Returns a resource within a trac project path. If a file is available |
|---|
| | 170 | in a corresponding path from the subdirectory 'trac', a static file |
|---|
| | 171 | resource to it is returned instead of a TracResource. |
|---|
| | 172 | """ |
|---|
| | 173 | def extendRequest(*newSegments): |
|---|
| | 174 | newSegments = list(newSegments) |
|---|
| | 175 | request.postpath.extend(newSegments) |
|---|
| | 176 | subSegments.extend(newSegments) |
|---|
| | 177 | addition = "/" + "/".join(newSegments) |
|---|
| | 178 | request.uri = request.uri.rstrip("/") + addition |
|---|
| | 179 | |
|---|
| | 180 | projectName, subSegments = segments[0], segments[1:] |
|---|
| | 181 | if not subSegments: |
|---|
| | 182 | extendRequest('wiki') |
|---|
| | 183 | if len(subSegments) == 1: |
|---|
| | 184 | section = subSegments[0] |
|---|
| | 185 | if section == 'wiki': |
|---|
| | 186 | extendRequest("Start_%s" % projectName) |
|---|
| | 187 | elif section == 'browser': |
|---|
| | 188 | extendRequest('projects', self._reformat(projectName), 'trunk') |
|---|
| | 189 | elif section == 'api': |
|---|
| | 190 | subSegments.append("classIndex.html") |
|---|
| | 191 | if subSegments[0] == 'api': |
|---|
| | 192 | return self.apiResource(projectName, subSegments[1]), () |
|---|
| | 193 | else: |
|---|
| | 194 | possibleResult = self._possibleStatic('trac', *subSegments) |
|---|
| | 195 | if possibleResult: |
|---|
| | 196 | return possibleResult, () |
|---|
| | 197 | return self.tr, subSegments |
|---|
| | 198 | |
|---|
| | 199 | def apiResource(self, projectName, fileName): |
|---|
| | 200 | """ |
|---|
| | 201 | Returns a L{static.File} child resource directed to an API document for |
|---|
| | 202 | the specified project, dynamically generating the document with |
|---|
| | 203 | pyDoctor as needed. |
|---|
| | 204 | |
|---|
| | 205 | TODO: SVN export, pydoctor, static.File(...), temp file cleanup |
|---|
| | 206 | """ |
|---|
| | 207 | projectDir = self._reformat(projectName) |
|---|
| | 208 | return self._possibleStatic('api', projectDir, fileName) |
|---|