Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 886

Show
Ignore:
Timestamp:
12/28/05 05:33:09
Author:
rdelon
Message:

More PEP 8 (including objectPath -> object_path); Changed virtualhostfilter to conform to PEP8; Fixes to sessionauthenticatefilter

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cphttptools.py

    r884 r886  
    2727        self.remoteHost = remoteHost 
    2828        self.scheme = scheme 
    29         self.executeMain = True 
     29        self.execute_main = True 
    3030        self.closed = False 
    3131     
     
    7575             
    7676            # This has to be done very early in the request process, 
    77             # because request.objectPath is used for config lookups 
     77            # because request.object_path is used for config lookups 
    7878            # right away. 
    7979            self.processRequestLine() 
     
    9393                        try: 
    9494                            applyFilters('before_main') 
    95                             if self.executeMain: 
     95                            if self.execute_main: 
    9696                                self.main() 
    9797                            break 
    9898                        except cherrypy.InternalRedirect, ir: 
    99                             self.objectPath = ir.path 
     99                            self.object_path = ir.path 
    100100                     
    101101                    applyFilters('before_finalize') 
     
    138138        self.protocol = proto 
    139139         
    140         # Change objectPath in filters to change 
     140        # Change object_path in filters to change 
    141141        # the object that will get rendered 
    142         self.objectPath = path 
     142        self.object_path = path 
    143143         
    144144        # Compare request and server HTTP versions, in case our server does 
     
    238238        """Obtain and set cherrypy.response.body from a page handler.""" 
    239239        if path is None: 
    240             path = self.objectPath 
     240            path = self.object_path 
    241241         
    242242        page_handler, object_path, virtual_path = self.mapPathToObject(path) 
     
    245245        virtual_path = [x.replace("%2F", "/") for x in virtual_path] 
    246246         
    247         # Remove "root" from object_path and join it to get objectPath 
    248         self.objectPath = '/' + '/'.join(object_path[1:]) 
     247        # Remove "root" from object_path and join it to get object_path 
     248        self.object_path = '/' + '/'.join(object_path[1:]) 
    249249        try: 
    250250            body = page_handler(*virtual_path, **self.params) 
  • trunk/cherrypy/_cputil.py

    r862 r886  
    1818    if objectpath is None: 
    1919        try: 
    20             objectpath = cherrypy.request.objectPath 
     20            objectpath = cherrypy.request.object_path 
    2121        except AttributeError: 
    2222            pass 
  • trunk/cherrypy/config.py

    r877 r886  
    9696    if path is None: 
    9797        try: 
    98             path = cherrypy.request.objectPath 
     98            path = cherrypy.request.object_path 
    9999        except AttributeError: 
    100             # There's no request.objectPath yet, so use the global settings. 
     100            # There's no request.object_path yet, so use the global settings. 
    101101            path = "global" 
    102102     
     
    158158     
    159159    try: 
    160         path = cherrypy.request.objectPath 
     160        path = cherrypy.request.object_path 
    161161    except AttributeError: 
    162162        return results 
  • trunk/cherrypy/filters/sessionauthenticatefilter.py

    r869 r886  
    2727     
    2828    def before_main(self): 
     29        cherrypy.request.user = None 
     30        cherrypy.thread_data.user = None 
     31 
    2932        conf = cherrypy.config.get 
    3033        if ((not conf('session_authenticate_filter.on', False)) 
     
    4346            cherrypy.session[session_key] = None 
    4447            cherrypy.request.user = None 
     48            cherrypy.thread_data.user = None 
    4549            from_page = cherrypy.request.params.get('from_page', '..') 
    4650            raise cherrypy.HTTPRedirect(from_page) 
     
    5256            if error_msg: 
    5357                cherrypy.response.body = login_screen(from_page, login = login, error_msg = error_msg) 
    54                 cherrypy.request.executeMain = False 
     58                cherrypy.request.execute_main = False 
    5559            else: 
    5660                cherrypy.session[session_key] = login 
     
    6165 
    6266        # Check if user is logged in 
     67        temp_user = None 
    6368        if (not cherrypy.session.get(session_key)) and not_logged_in: 
    6469            # Call not_logged_in so that applications where anynymous user 
    6570            #   is OK can handle it 
    66             not_logged_in() 
    67         if not cherrypy.session.get(session_key)
     71            temp_user = not_logged_in() 
     72        if (not cherrypy.session.get(session_key)) and not temp_user
    6873            cherrypy.response.body = login_screen(cherrypy.request.browser_url) 
    69             cherrypy.request.executeMain = False 
     74            cherrypy.request.execute_main = False 
    7075            return 
    7176         
    7277        # Everything is OK: user is logged in 
    73         if load_user_by_username
    74             username = cherrypy.session[session_key] 
     78        if load_user_by_username and not cherrypy.thread_data.user
     79            username = temp_user or cherrypy.session[session_key] 
    7580            cherrypy.request.user = load_user_by_username(username) 
    7681            cherrypy.thread_data.user = load_user_by_username(username) 
  • trunk/cherrypy/filters/staticfilter.py

    r878 r886  
    1616         
    1717        request = cherrypy.request 
    18         path = request.objectPath 
     18        path = request.object_path 
    1919         
    2020        regex = config.get('static_filter.match', '') 
     
    4444        try:         
    4545            cptools.serveFile(filename) 
    46             request.executeMain = False 
     46            request.execute_main = False 
    4747        except cherrypy.NotFound: 
    4848            # if we didn't find the static file, continue 
  • trunk/cherrypy/filters/virtualhostfilter.py

    r883 r886  
    3131         
    3232        domain = cherrypy.request.headers.get('Host', '') 
    33         if cherrypy.config.get("virtual_host_filter.useXForwardedHost", True): 
     33        if cherrypy.config.get("virtual_host_filter.use_x_forwarded_host", True): 
    3434            domain = cherrypy.request.headers.get("X-Forwarded-Host", domain) 
    3535         
    3636        prefix = cherrypy.config.get("virtual_host_filter." + domain, "") 
    3737        if prefix: 
    38             cherrypy.request.objectPath = prefix + "/" + cherrypy.request.objectPath 
     38            cherrypy.request.object_path = prefix + "/" + cherrypy.request.object_path 
    3939 
  • trunk/cherrypy/filters/xmlrpcfilter.py

    r856 r886  
    9696        Unmarshalls the posted data to a methodname and parameters. 
    9797        - These are stored in cherrypy.request.rpcMethod and .rpcParams 
    98         - The method is also stored in cherrypy.request.objectPath, 
     98        - The method is also stored in cherrypy.request.object_path, 
    9999          so CP2 will find the right method to call for you, 
    100100          based on the root's position. 
     
    139139        # - 'someurl' + method >> someurl.method 
    140140        # - 'someurl/someother' + method >> someurl.someother.method 
    141         if not request.objectPath.endswith('/'): 
    142             request.objectPath += '/' 
    143         if request.objectPath.startswith('/RPC2/'): 
     141        if not request.object_path.endswith('/'): 
     142            request.object_path += '/' 
     143        if request.object_path.startswith('/RPC2/'): 
    144144            # strip the first /rpc2 
    145             request.objectPath = request.objectPath[5:] 
    146         request.objectPath += str(method).replace('.', '/') 
     145            request.object_path = request.object_path[5:] 
     146        request.object_path += str(method).replace('.', '/') 
    147147        request.paramList = list(params) 
    148148     
     
    159159            return 
    160160         
    161         path = cherrypy.request.objectPath 
     161        path = cherrypy.request.object_path 
    162162        while True: 
    163163            try: 
     
    167167                virtual_path = [x.replace("%2F", "/") for x in virtual_path] 
    168168                 
    169                 # Remove "root" from object_path and join it to get objectPath 
    170                 self.objectPath = '/' + '/'.join(object_path[1:]) 
     169                # Remove "root" from object_path and join it to get object_path 
     170                self.object_path = '/' + '/'.join(object_path[1:]) 
    171171                args = virtual_path + cherrypy.request.paramList 
    172172                body = page_handler(*args, **cherrypy.request.params) 
     
    183183                               encoding=encoding, allow_none=0) 
    184184        self.respond(body) 
    185         cherrypy.request.executeMain = False 
     185        cherrypy.request.execute_main = False 
    186186     
    187187    def after_error_response(self): 
  • trunk/cherrypy/test/helper.py

    r885 r886  
    5151     
    5252    def on_start_resource(self): 
    53         path = cherrypy.request.objectPath 
     53        path = cherrypy.request.object_path 
    5454        if path.startswith(self.prefix): 
    55             cherrypy.request.objectPath = path[len(self.prefix):] 
     55            cherrypy.request.object_path = path[len(self.prefix):] 
    5656vroot = "" 
    5757##vroot = "/vpath" 
  • trunk/cherrypy/test/test_objectmapping.py

    r856 r886  
    5757     
    5858    def myMethod(self): 
    59         return "myMethod from dir1, object Path is:" + repr(cherrypy.request.objectPath) 
     59        return "myMethod from dir1, object Path is:" + repr(cherrypy.request.object_path) 
    6060    myMethod.exposed = True 
    6161     

Hosted by WebFaction

Log in as guest/cpguest to create tickets