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

« back to all changes in this revision

Viewing changes to lib/fileservice_lib/action.py

  • Committer: drtomc
  • Date: 2008-02-20 09:41:48 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:522
Add quite a lot of stuff to get usrmgt happening.

login.py: A little bit of robustifying logic that logs you out if your account
    is still pending when you try to auth. Basically, this forces usrmgt-server
    to have another try.

authenticate.py: A small code rearrangement to produce the right behaviour
    (a generic login/passwd error) when an unknown user logs in (better than
    an internal server error :-) ).

usrmgt-server, makeuser.py: Lots of stuff to setup users. Quite a bit of stuff
    that should be db-driven is hard coded at the moment. (Only a week and a
    half till students will be hitting it, and we can't do everything!)

setup.py: Add an extra bit of svn related config.

users.sql,user.py,db.py: Add the svn_pass column to allow ivle to auth to the
    subversion server.

studpath.py: update a couple of comments to reflect a newer view of the world.

python-console: Add some timeout magic. Actually, I don't think this works,
    but it's well after bedtime, and I've still got to ride home from work.
    The morning will be soon enough.

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
#               recursively.
120
120
#       logmsg: Text of the log message. Optional. There is a default log
121
121
#               message if unspecified.
 
122
# action=svncheckout: Checkout a file/directory from the repository.
 
123
#       path:   The [repository] path to the file or directory to be
 
124
#               checked out.
122
125
123
126
# TODO: Implement the following actions:
124
127
#   putfiles, svnrevert, svnupdate, svncommit
136
139
import pysvn
137
140
 
138
141
from common import (util, studpath, zip)
 
142
import conf
 
143
 
 
144
def get_login(_realm, _username, _may_save):
 
145
    """Return the subversion credentials for the user."""
 
146
    return (True, conf.login, conf.passwd, True)
139
147
 
140
148
# Make a Subversion client object
141
149
svnclient = pysvn.Client()
 
150
svnclient.callback_get_login = get_login
142
151
 
143
152
DEFAULT_LOGMESSAGE = "No log message supplied."
144
153
 
548
557
    except pysvn.ClientError:
549
558
        raise ActionError("One or more files could not be committed")
550
559
 
 
560
def action_svncheckout(req, fields):
 
561
    """Performs a "svn checkout" of each path specified.
 
562
 
 
563
    Reads fields: 'path'    (multiple)
 
564
    """
 
565
    paths = fields.getlist('path')
 
566
    if len(paths) != 2:
 
567
        raise ActionError("usage: svncheckout url local-path")
 
568
    url = conf.svn_addr + "/" + login + "/" + paths[0]
 
569
    local_path = actionpath_to_local(req, str(paths[1]))
 
570
    try:
 
571
        svnclient.callback_get_login = get_login
 
572
        svnclient.checkout(url, local_path, recurse=True)
 
573
    except pysvn.ClientError:
 
574
        raise ActionError("One or more files could not be checked out")
 
575
 
551
576
# Table of all action functions #
552
577
# Each function has the interface f(req, fields).
553
578
 
567
592
    "svnpublish" : action_svnpublish,
568
593
    "svnunpublish" : action_svnunpublish,
569
594
    "svncommit" : action_svncommit,
 
595
    "svncheckout" : action_svncheckout,
570
596
}