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

« back to all changes in this revision

Viewing changes to ivle/database.py

  • Committer: David Coles
  • Date: 2010-07-20 05:55:20 UTC
  • Revision ID: coles.david@gmail.com-20100720055520-yxyfn2qqycfwboiq
URL quote paths in checkout URLs.

The two benefits of this are that we no longer have issues with spaces in 
submitted paths and also don't have to worry about shell escape characters 
(and possible shell injection to a lectures console).

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
import datetime
28
28
import os
29
29
import urlparse
 
30
import urllib
30
31
 
31
32
from storm.locals import create_database, Store, Int, Unicode, DateTime, \
32
33
                         Reference, ReferenceSet, Bool, Storm, Desc
911
912
        return "/files/%s/%s/%s?r=%d" % (user.login,
912
913
            self.assessed.checkout_location, submitpath, self.revision)
913
914
 
 
915
    def get_svn_url(self, req):
 
916
        """Get subversion URL for this submission"""
 
917
        princ = self.assessed.principal
 
918
        base = princ.get_svn_url(req.config, req)
 
919
        if self.path.startswith(os.sep):
 
920
            return os.path.join(base,
 
921
                    urllib.quote(self.path[1:].encode('utf-8')))
 
922
        else:
 
923
            return os.path.join(base, urllib.quote(self.path.encode('utf-8')))
 
924
 
 
925
    def get_svn_checkout_command(self, req):
 
926
        svn_url = self.get_svn_url(req)
 
927
        return "svn export -r%d '%s'"%(self.revision, svn_url)
 
928
 
914
929
    @staticmethod
915
930
    def test_and_normalise_path(path):
916
931
        """Test that path is valid, and normalise it. This prevents possible