site/request.py
changeset 3 84a149e35cbe
parent 2 ec68a0f75c58
equal deleted inserted replaced
2:ec68a0f75c58 3:84a149e35cbe
     5     """
     5     """
     6         Get the URL that points to the site root (i.e. where style.css is) using the given value of SCRIPT_NAME
     6         Get the URL that points to the site root (i.e. where style.css is) using the given value of SCRIPT_NAME
     7 
     7 
     8         /foo/bar/quux.py                -> /foo
     8         /foo/bar/quux.py                -> /foo
     9         /~terom/qmsk.net/site/index.py  -> /~terom/qmsk.net
     9         /~terom/qmsk.net/site/index.py  -> /~terom/qmsk.net
    10         None                            -> /
    10         /                               -> ""
       
    11         None                            -> ""
    11     """
    12     """
    12     
    13     
    13     if script_name :
    14     if script_name :
    14         return os.path.dirname(os.path.dirname(script_name))
    15         return os.path.dirname(os.path.dirname(script_name)).rstrip("/")
    15     else :
    16     else :
    16         return "/"
    17         return ""
    17 
    18 
    18 def get_page_path (path_info, default) :
    19 def get_page_path (path_info, default) :
    19     """
    20     """
    20         Get the path of the page that was requested, or the given default is empty/invalid.
    21         Get the path of the page that was requested, or the given default is empty/invalid.
    21         The path will never begin with an /.
    22         The path will never begin with an /.