devtools/testlib.py
branchstable
changeset 6166 fc47b4e06d94
parent 6165 7da7c270bbbd
child 6167 376e6c3d4002
equal deleted inserted replaced
6165:7da7c270bbbd 6166:fc47b4e06d94
   548             req.cnx.commit()
   548             req.cnx.commit()
   549         except web.Redirect:
   549         except web.Redirect:
   550             req.cnx.commit()
   550             req.cnx.commit()
   551             raise
   551             raise
   552         return result
   552         return result
       
   553 
       
   554     def req_from_url(self, url):
       
   555         """parses `url` and builds the corresponding CW-web request
       
   556 
       
   557         req.form will be setup using the url's query string
       
   558         """
       
   559         req = self.request()
       
   560         if isinstance(url, unicode):
       
   561             url = url.encode(req.encoding) # req.setup_params() expects encoded strings
       
   562         querystring = urlparse.urlparse(url)[-2]
       
   563         params = urlparse.parse_qs(querystring)
       
   564         req.setup_params(params)
       
   565         return req
       
   566 
       
   567     def url_publish(self, url):
       
   568         """takes `url`, uses application's app_resolver to find the
       
   569         appropriate controller, and publishes the result.
       
   570 
       
   571         This should pretty much correspond to what occurs in a real CW server
       
   572         except the apache-rewriter component is not called.
       
   573         """
       
   574         req = self.req_from_url(url)
       
   575         ctrlid, rset = self.app.url_resolver.process(req, req.relative_path(False))
       
   576         return self.ctrl_publish(req, ctrlid)
   553 
   577 
   554     def expect_redirect(self, callback, req):
   578     def expect_redirect(self, callback, req):
   555         """call the given callback with req as argument, expecting to get a
   579         """call the given callback with req as argument, expecting to get a
   556         Redirect exception
   580         Redirect exception
   557         """
   581         """