Changeset 47

Show
Ignore:
Timestamp:
07/23/07 20:14:29 (1 year ago)
Author:
edsuom
Message:

VHost fixes; updated foss.tellectual.com example

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • projects/twisted-goodies/trunk/misc/var_www_foss.tellectual.com_index.py

    r42 r47  
    104104            {'PYTHON_EGG_CACHE': ospath.join(TRAC_DIR, 'python-eggs')}} 
    105105        self.tr = TracResource(TRAC_DIR, env) 
    106      
     106 
     107    def _reformat(self, name): 
     108        return name.replace("-", "_").lower() 
     109 
     110    def _possibleStatic(self, *pathParts): 
     111        staticPath = ospath.join(self.vhostPath, *pathParts) 
     112        if ospath.exists(staticPath): 
     113            return static.File(staticPath) 
     114 
    107115    def render(self, request): 
    108116        """ 
     
    113121            projectDescription = " ".join( 
    114122                [x.strip() for x in doc.strip().split("\n")]) 
    115             href = "/trac/wiki/%s" % projectName 
     123            href = "/trac/%s/wiki/Start_%s" % (projectName, projectName) 
    116124            projectDiv = [ 
    117125                T.a(id="project_link", href=href)[projectName]] 
     
    146154        return T.p(id="footer")[self.html(contents)] 
    147155 
    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  
    160156    def locateChild(self, request, segments): 
    161157        """ 
     
    168164            return self.tracChild(request, segments[1:]) 
    169165        return static.File(ospath.join(self.vhostPath, *segments)), () 
     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) 
  • projects/twisted-goodies/trunk/twisted_goodies/simpleserver/http/startup.py

    r45 r47  
    150150            if not os.path.isdir(dirPath): 
    151151                continue 
    152             if not self.reAlpha.search(dirName): 
    153                 continue 
    154             if not self.reNum.search(dirName): 
    155                 continue 
    156             yield dirName, dirPath 
     152            if self.reAlpha.search(dirName) or self.reNum.search(dirName): 
     153                yield dirName, dirPath 
    157154 
  • projects/twisted-goodies/trunk/twisted_goodies/simpleserver/http/wsgi.py

    r17 r47  
    1616 
    1717 
    18 VERBOSE = Tru
     18VERBOSE = Fals
    1919MAX_PENDING = 10 
    2020IP_BAN_SECS = 30.0 
     
    112112            200, 
    113113            {'content-type': http_headers.MimeType('text', 'html')}, html) 
    114  
    115114     
    116115    def locateChild(self, request, segments): 
     
    223222        if size < 0: 
    224223            size = None 
    225         return self.callInReactor(self.stream.readExactly, size) 
     224        result = self.callInReactor(self.stream.readExactly, size) 
     225        return result 
    226226 
    227227    def readline(self):