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

Changeset 1699

Show
Ignore:
Timestamp:
07/21/07 12:24:26
Author:
fumanchu
Message:

Added builtins and subscript to unrepr.

Files:

Legend:

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

    r1620 r1699  
    4646        return m(o) 
    4747     
     48    def build_Subscript(self, o): 
     49        expr, flags, subs = o.getChildren() 
     50        expr = self.build(expr) 
     51        subs = self.build(subs) 
     52        return expr[subs] 
     53     
    4854    def build_CallFunc(self, o): 
    4955        children = map(self.build, o.getChildren()) 
     
    8288            return modules(o.name) 
    8389        except ImportError: 
     90            pass 
     91         
     92        # See if the Name is in __builtin__. 
     93        try: 
     94            import __builtin__ 
     95            return getattr(__builtin__, o.name) 
     96        except AttributeError: 
    8497            pass 
    8598         
  • trunk/cherrypy/test/test_config.py

    r1698 r1699  
    9191neg: -1234 
    9292filename: os.path.join(sys.prefix, "hello.py") 
     93thing1: cherrypy.lib.http.response_codes[404] 
     94thing2: __import__('cherrypy.tutorial', globals(), locals(), ['']).thing2 
    9395 
    9496[/favicon.ico] 
     
    161163        self.getPage("/repr?key=filename") 
    162164        self.assertBody(repr(os.path.join(sys.prefix, "hello.py"))) 
     165         
     166        self.getPage("/repr?key=thing1") 
     167        self.assertBody(repr(cherrypy.lib.http.response_codes[404])) 
     168         
     169        self.getPage("/repr?key=thing2") 
     170        from cherrypy.tutorial import thing2 
     171        self.assertBody(repr(thing2)) 
    163172     
    164173    def testCustomNamespaces(self): 
  • trunk/cherrypy/tutorial/__init__.py

    r762 r1699  
     1 
     2# This is used in test_config to test unrepr of "from A import B" 
     3thing2 = object() 

Hosted by WebFaction

Log in as guest/cpguest to create tickets