~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/apps/consoleservice/__init__.py

  • Committer: dcoles
  • Date: 2008-07-15 06:10:20 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:872
Console: Allow console to be started with a set working directory (defaults to 
home)

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
        req.throw_error(req.HTTP_BAD_REQUEST)
58
58
 
59
59
def handle_start(req):
60
 
    jail_path = os.path.join(conf.jail_base, req.user.login)
61
 
    working_dir = os.path.join("/home", req.user.login)   # Within jail
 
60
    # Changes the state on the server - must be POST
 
61
    if req.method != "POST":
 
62
        req.throw_error(req.HTTP_BAD_REQUEST)
 
63
    
 
64
    # See if we have been given extra params
 
65
    fields = req.get_fieldstorage()
 
66
    try:
 
67
        startdir = fields.getfirst("startdir").value
 
68
        working_dir = os.path.join("/home", req.user.login, startdir)
 
69
    except AttributeError:
 
70
        working_dir = os.path.join("/home", req.user.login)
62
71
 
63
72
    # Get the UID of the logged-in user
64
73
    uid = req.user.unixid
68
77
    req.write_html_head_foot = False
69
78
 
70
79
    # Start the server
 
80
    jail_path = os.path.join(conf.jail_base, req.user.login)
71
81
    (host, port, magic) = start_console(uid, jail_path, working_dir)
72
82
 
73
83
    # Assemble the key and return it.