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

« back to all changes in this revision

Viewing changes to lib/common/studpath.py

  • Committer: dcoles
  • Date: 2008-04-04 04:29:45 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:724
public mode: Backend changes to enable public mode. So long as the folder is 
world readable and a '.published' file is in the folder then files can be 
viewed through the public url.

    w/a/s/__init__.py: Bug fix - now uses the owner param of server_file
    l/c/studpath.py: Now uses worldreadable+'.published' file for permission 
    rather than svn properties

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)