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

Changeset 1485

Show
Ignore:
Timestamp:
12/09/06 13:08:43
Author:
fumanchu
Message:

2.x backport of [1093] (better errors on lookup of request attrs when not in a request). This was eventually removed in 3.0, but by a dummy Request object; that seemed too big an API change for 2.x.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/cherrypy-2.x/cherrypy/__init__.py

    r1484 r1485  
    4040     
    4141    def __getattr__(self, name): 
    42         childobject = getattr(serving, self.__attrname__) 
     42        try: 
     43            childobject = getattr(serving, self.__attrname__) 
     44        except AttributeError: 
     45            raise AttributeError("cherrypy.%s has no properties outside of " 
     46                                 "an HTTP request." % self.__attrname__) 
    4347        return getattr(childobject, name) 
    4448     
    4549    def __setattr__(self, name, value): 
    46         childobject = getattr(serving, self.__attrname__) 
     50        try: 
     51            childobject = getattr(serving, self.__attrname__) 
     52        except AttributeError: 
     53            raise AttributeError("cherrypy.%s has no properties outside of " 
     54                                 "an HTTP request." % self.__attrname__) 
    4755        setattr(childobject, name, value) 
    4856     
    4957    def __delattr__(self, name): 
    50         childobject = getattr(serving, self.__attrname__) 
     58        try: 
     59            childobject = getattr(serving, self.__attrname__) 
     60        except AttributeError: 
     61            raise AttributeError("cherrypy.%s has no properties outside of " 
     62                                 "an HTTP request." % self.__attrname__) 
    5163        delattr(childobject, name) 
    5264 

Hosted by WebFaction

Log in as guest/cpguest to create tickets