Changeset 2655


Ignore:
Timestamp:
Dec 20, 2009, 8:26:02 PM (15 years ago)
Author:
price
Message:

Deduplicate the code in auth.fcgi and unauth.fcgi

But call the reunited code "invirt.fcgi" rather than the old "main.fcgi",
which was always annoying for tab-completion against "main.py".

Location:
package_branches/invirt-web/cherrypy/code
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • package_branches/invirt-web/cherrypy/code/auth.fcgi

    • Property svn:executable deleted
    • Property svn:special set to *
    r2654 r2655  
    1 #!/usr/bin/python
    2 """Main FastCGI entry point for authenticated web interface"""
    3 
    4 import cherrypy
    5 import os
    6 import sys
    7 from main import InvirtWeb
    8 
    9 dev = False
    10 base_dir = os.path.dirname(__file__)
    11 
    12 def usage():
    13     print >>sys.stderr, """%s [config]
    14 
    15 Run server as FastCGI, with CherryPy config from "main.conf".
    16 
    17 With `config`, run standalone with CherryPy config from `config`.
    18 """ % sys.argv[0]
    19     sys.exit(2)
    20 
    21 if __name__ == "__main__":
    22     if len(sys.argv) > 2:
    23         usage()
    24     if len(sys.argv) > 1:
    25         if sys.argv[1] in ('-h', '--help'):
    26             usage()
    27         conf_file = sys.argv[1]
    28         dev = True
    29     else:
    30         conf_file = os.path.join(base_dir, 'main.conf')
    31 
    32     app_config = {
    33         '/': {
    34             'tools.invirtwebstate.on': True,
    35             },
    36         }
    37                    
    38     app = cherrypy.tree.mount(InvirtWeb(),
    39                               '/',
    40                               app_config)
    41     app.merge(conf_file)
    42     cherrypy.config.update(conf_file)
    43 
    44     if dev:
    45         cherrypy.server.quickstart()
    46         cherrypy.engine.start()
    47         cherrypy.engine.block()
    48     else:
    49         cherrypy.engine.start(blocking=False)
    50         from flup.server.fcgi import WSGIServer
    51         server = WSGIServer(cherrypy.tree)
    52         server.run()
     1link invirt.fcgi
  • package_branches/invirt-web/cherrypy/code/invirt.fcgi

    • Property svn:executable deleted
    r2654 r2655  
    11#!/usr/bin/python
    2 """Main FastCGI entry point for unauthenticated web interface"""
     2"""Main FastCGI entry point for web interface"""
    33
    44import cherrypy
    55import os
    66import sys
    7 from main import InvirtUnauthWeb
     7
     8import main
    89
    910dev = False
     
    1617
    1718With `config`, run standalone with CherryPy config from `config`.
     19
     20Run this script as either 'auth.fcgi' or 'unauth.fcgi', to get
     21the authenticated or unauthenticated site respectively.
    1822""" % sys.argv[0]
    1923    sys.exit(2)
     
    3539            },
    3640        }
    37                    
    38     app = cherrypy.tree.mount(InvirtUnauthWeb(),
    39                               '/',
    40                               app_config)
     41
     42    if os.path.basename(sys.argv[0]).startswith('auth'):
     43        root = InvirtWeb()
     44    elif os.path.basename(sys.argv[0]).startswith('unauth'):
     45        root = InvirtUnauthWeb()
     46    else:
     47        usage()
     48
     49    app = cherrypy.tree.mount(root, '/', app_config)
    4150    app.merge(conf_file)
    4251    cherrypy.config.update(conf_file)
  • package_branches/invirt-web/cherrypy/code/unauth.fcgi

    • Property svn:executable deleted
    • Property svn:special set to *
    r2654 r2655  
    1 #!/usr/bin/python
    2 """Main FastCGI entry point for unauthenticated web interface"""
    3 
    4 import cherrypy
    5 import os
    6 import sys
    7 from main import InvirtUnauthWeb
    8 
    9 dev = False
    10 base_dir = os.path.dirname(__file__)
    11 
    12 def usage():
    13     print >>sys.stderr, """%s [config]
    14 
    15 Run server as FastCGI, with CherryPy config from "main.conf".
    16 
    17 With `config`, run standalone with CherryPy config from `config`.
    18 """ % sys.argv[0]
    19     sys.exit(2)
    20 
    21 if __name__ == "__main__":
    22     if len(sys.argv) > 2:
    23         usage()
    24     if len(sys.argv) > 1:
    25         if sys.argv[1] in ('-h', '--help'):
    26             usage()
    27         conf_file = sys.argv[1]
    28         dev = True
    29     else:
    30         conf_file = os.path.join(base_dir, 'main.conf')
    31 
    32     app_config = {
    33         '/': {
    34             'tools.invirtwebstate.on': True,
    35             },
    36         }
    37                    
    38     app = cherrypy.tree.mount(InvirtUnauthWeb(),
    39                               '/',
    40                               app_config)
    41     app.merge(conf_file)
    42     cherrypy.config.update(conf_file)
    43 
    44     if dev:
    45         cherrypy.server.quickstart()
    46         cherrypy.engine.start()
    47         cherrypy.engine.block()
    48     else:
    49         cherrypy.engine.start(blocking=False)
    50         from flup.server.fcgi import WSGIServer
    51         server = WSGIServer(cherrypy.tree)
    52         server.run()
     1link invirt.fcgi
Note: See TracChangeset for help on using the changeset viewer.