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

« back to all changes in this revision

Viewing changes to lib/common/studpath.py

  • Committer: mattgiuca
  • Date: 2008-07-07 12:01:03 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:820
lib: Added new package pulldown_subj, a collection of modules designed to
    pull student subject enrolments from the server.
    Note that the actual code to do this is not included (since that is
    specific to the organisation running IVLE) - just a pluggable interface
    and an example plugin module.
configure.py: Added new config option: subject_pulldown_modules, which allows
    you to specify which modules are plugged in here.
    (Actually that was added accidentally in a previous commit; but this
    revision fixes some comments).

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
# they dont own.
26
26
 
27
27
import os
28
 
 
 
28
import stat
29
29
import pysvn
30
30
 
31
31
import conf
101
101
 
102
102
    return (user, jail, path)
103
103
 
104
 
def published(path):
 
104
def svnpublished(path):
105
105
    """Given a path on the LOCAL file system, determines whether the path has
106
106
    its "ivle:published" property active (in subversion). Returns True
107
107
    or False."""
113
113
        return False
114
114
    return len(props) > 0
115
115
 
 
116
def published(path):
 
117
    """Given a path on the LOCAL file system, determines whether the path has a 
 
118
    '.published' file.  Returns True or False."""
 
119
    publish_file_path = os.path.join(path,'.published')
 
120
    return os.access(publish_file_path,os.F_OK)
 
121
 
 
122
def worldreadable(path):
 
123
    """Given a path on the LOCAL file system, determines whether the path is 
 
124
    world readble. Returns True or False."""
 
125
    try:
 
126
        mode = os.stat(path).st_mode
 
127
        if mode & stat.S_IROTH:
 
128
            return True
 
129
        else:
 
130
            return False
 
131
    except OSError, e:
 
132
        return False
 
133
 
 
134
 
116
135
def authorize(req):
117
136
    """Given a request, checks whether req.user is allowed to
118
137
    access req.path. Returns None on authorization success. Raises
144
163
    """
145
164
    _, path = url_to_local(req.path)
146
165
    dirpath, _ = os.path.split(path)
147
 
    if not published(dirpath):
 
166
    if not (worldreadable(dirpath) and published(dirpath)):
148
167
        req.throw_error(req.HTTP_FORBIDDEN)