source: TI04-geosplat/trunk/pygss/ResourceAccess.py @ 798

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI04-geosplat/trunk/pygss/ResourceAccess.py@798
Revision 798, 1.3 KB checked in by astephen, 14 years ago (diff)

Latest working version with install method.
Can accept more than one file but doesn't combine variables yet.

Line 
1#   Copyright (C) 2004 CCLRC & NERC( Natural Environment Research Council ).
2#   This software may be distributed under the terms of the
3#   Q Public License, version 1.0 or later. http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt
4
5"""
6ResourceAccess.py
7=================
8
9ResourceAccess class works out if a user is allowed to access a particular
10resource URI (typically a file).
11
12""" 
13
14# Import library modules
15import os, sys
16
17# Import package modules
18from serverConfig import *
19
20
21class ResourceAccess:
22    """
23    ResourceAccess class works out if a user is allowed to access a particular
24    resource URI (typically a file).
25    """
26     
27    def __init__(self, resourceURI, username, userRoles):
28        """
29        Sets up instance variables and runs checks.
30        """
31        uri=resourceURI
32        self.username=username
33        self.userRoles=userRoles
34        if uri.split("//")[0]=="file":
35            self.access=self.checkSystemFileCheck(uri)
36        else:
37            raise "Remote file and service-based access not yet implemented."
38           
39    def checkSystemFileCheck(self, uri):
40        """
41        Returns 1 if user is allowed to see the file and 0 otherwise.
42        If cannot get to file then raises an error.
43        """
44        if not os.path.isfile(uri):
45            raise GSFileIOError, ("File '%s' does not exist." % uri)
46       
47        raise "Not yet implemented."
Note: See TracBrowser for help on using the repository browser.