CherryPy / cherrypy / __init__.py

Diff from to

cherrypy/__init__.py

 
 # Timeout monitor
 class _TimeoutMonitor(process.plugins.Monitor):
-
+    
     def __init__(self, bus):
         self.servings = []
         process.plugins.Monitor.__init__(self, bus, self.run)
-
+    
     def acquire(self):
         self.servings.append((serving.request, serving.response))
-
+    
     def release(self):
         try:
             self.servings.remove((serving.request, serving.response))
         except ValueError:
             pass
-
+    
     def run(self):
         """Check timeout on all responses. (Internal)"""
         for req, resp in self.servings:
 
 def quickstart(root=None, script_name="", config=None):
     """Mount the given root, start the builtin server (and engine), then block.
-
+    
     root: an instance of a "controller class" (a collection of page handler
         methods) which represents the root of the application.
     script_name: a string containing the "mount point" of the application.
         at which to mount the given root. For example, if root.index() will
         handle requests to "http://www.example.com:8080/dept/app1/", then
         the script_name argument would be "/dept/app1".
-
+        
         It MUST NOT end in a slash. If the script_name refers to the root
         of the URI, it MUST be an empty string (not "/").
     config: a file or dict containing application config. If this contains
     """
     if config:
         _global_conf_alias.update(config)
-
+    
     tree.mount(root, script_name, config)
-
+    
     if hasattr(engine, "signal_handler"):
         engine.signal_handler.subscribe()
     if hasattr(engine, "console_control_handler"):
         engine.console_control_handler.subscribe()
-
+    
     engine.start()
     engine.block()
 
 
 class _Serving(_local):
     """An interface for registering request and response objects.
-
+    
     Rather than have a separate "thread local" object for the request and
     the response, this class works as a single threadlocal container for
     both objects (and any others which developers wish to define). In this
 
 
 class _ThreadLocalProxy(object):
-
+    
     __slots__ = ['__attrname__', '__dict__']
-
+    
     def __init__(self, attrname):
         self.__attrname__ = attrname
-
+    
     def __getattr__(self, name):
         child = getattr(serving, self.__attrname__)
         return getattr(child, name)
-
+    
     def __setattr__(self, name, value):
         if name in ("__attrname__", ):
             object.__setattr__(self, name, value)
         else:
             child = getattr(serving, self.__attrname__)
             setattr(child, name, value)
-
+    
     def __delattr__(self, name):
         child = getattr(serving, self.__attrname__)
         delattr(child, name)
-
+    
     def _get_dict(self):
         child = getattr(serving, self.__attrname__)
         d = child.__class__.__dict__.copy()
         d.update(child.__dict__)
         return d
     __dict__ = property(_get_dict)
-
+    
     def __getitem__(self, key):
         child = getattr(serving, self.__attrname__)
         return child[key]
-
+    
     def __setitem__(self, key, value):
         child = getattr(serving, self.__attrname__)
         child[key] = value
-
+    
     def __delitem__(self, key):
         child = getattr(serving, self.__attrname__)
         del child[key]
-
+    
     def __contains__(self, key):
         child = getattr(serving, self.__attrname__)
         return key in child
-
+    
     def __len__(self):
         child = getattr(serving, self.__attrname__)
         return len(child)
-
+    
     def __nonzero__(self):
         child = getattr(serving, self.__attrname__)
         return bool(child)
                 for a in alias:
                     parents[a.replace(".", "_")] = func
         return func
-
+    
     import sys, types
     if isinstance(func, (types.FunctionType, types.MethodType)):
         if alias is None:
 
 def url(path="", qs="", script_name=None, base=None, relative=None):
     """Create an absolute URL for the given path.
-
+    
     If 'path' starts with a slash ('/'), this will return
         (base + script_name + path + qs).
     If it does not start with a slash, this returns
         (base + script_name [+ request.path_info] + path + qs).
-
+    
     If script_name is None, cherrypy.request will be used
     to find a script_name, if available.
-
+    
     If base is None, cherrypy.request.base will be used (if available).
     Note that you can use cherrypy.tools.proxy to change this.
-
+    
     Finally, note that this function can be used to obtain an absolute URL
     for the current request path (minus the querystring) by passing no args.
     If you call url(qs=cherrypy.request.query_string), you should get the
     original browser URL (assuming no internal redirections).
-
+    
     If relative is None or not provided, request.app.relative_urls will
     be used (if available, else False). If False, the output will be an
     absolute URL (including the scheme, host, vhost, and script_name).
         qs = _urlencode(qs)
     if qs:
         qs = '?' + qs
-
+    
     if request.app:
         if not path.startswith("/"):
             # Append/remove trailing slash from path_info as needed
             elif request.is_index is False:
                 if pi.endswith('/') and pi != '/':
                     pi = pi[:-1]
-
+            
             if path == "":
                 path = pi
             else:
                 path = _urljoin(pi, path)
-
+        
         if script_name is None:
             script_name = request.script_name
         if base is None:
             base = request.base
-
+        
         newurl = base + script_name + path + qs
     else:
         # No request.app (we're being called outside a request).
         # if you're using vhosts or tools.proxy.
         if base is None:
             base = server.base()
-
+        
         path = (script_name or "") + path
         newurl = base + path + qs
-
+    
     if './' in newurl:
         # Normalize the URL by removing ./ and ../
         atoms = []
             else:
                 atoms.append(atom)
         newurl = '/'.join(atoms)
-
+    
     # At this point, we should have a fully-qualified absolute URL.
-
+    
     if relative is None:
         relative = getattr(request.app, "relative_urls", False)
-
+    
     # See http://www.ietf.org/rfc/rfc2396.txt
     if relative == 'server':
         # "A relative reference beginning with a single slash character is
             new.pop(0)
         new = (['..'] * len(old)) + new
         newurl = '/'.join(new)
-
+    
     return newurl
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.