~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-17 11:32:50 UTC
  • Revision ID: coles.david@gmail.com-20100717113250-vi18n50bcjmfmzrt
Show warning for CGI header field-names which contain restricted characters.

Forbidden characters are the separators defined by RFC3875. This is mainly to 
fix an issue where printing a dictionary (with no CGI headers) could be 
assumed to be a CGI header with no warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import hashlib
27
27
import datetime
28
28
import os
 
29
import urlparse
29
30
 
30
31
from storm.locals import create_database, Store, Int, Unicode, DateTime, \
31
32
                         Reference, ReferenceSet, Bool, Storm, Desc
229
230
        """Find a user in a store by login name."""
230
231
        return store.find(cls, cls.login == unicode(login)).one()
231
232
 
 
233
    def get_svn_url(self, config, req):
 
234
        """Get the subversion repository URL for this user or group."""
 
235
        login = req.user.login
 
236
        url = urlparse.urlsplit(config['urls']['svn_addr'])
 
237
        url = urlparse.urlunsplit(url[:1] + (login+'@'+url[1],) + url[2:])
 
238
        path = 'users/%s' % self.login
 
239
        return urlparse.urljoin(url, path)
 
240
 
232
241
    def get_permissions(self, user, config):
233
242
        """Determine privileges held by a user over this object.
234
243
 
725
734
            Semester.id == Offering.semester_id,
726
735
            (not active_only) or (Semester.state == u'current'))
727
736
 
 
737
    def get_svn_url(self, config, req):
 
738
        """Get the subversion repository URL for this user or group."""
 
739
        login = req.user.login
 
740
        url = urlparse.urlsplit(config['urls']['svn_addr'])
 
741
        url = urlparse.urlunsplit(url[:1] + (login+'@'+url[1],) + url[2:])
 
742
        path = 'groups/%s_%s_%s_%s' % (
 
743
                self.project_set.offering.subject.short_name,
 
744
                self.project_set.offering.semester.year,
 
745
                self.project_set.offering.semester.semester,
 
746
                self.name
 
747
                )
 
748
        return urlparse.urljoin(url, path)
728
749
 
729
750
    def get_permissions(self, user, config):
730
751
        if user.admin or user in self.members: