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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI04-geosplat/trunk/pygss/CreditManager.py@798
Revision 798, 1.6 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"""
6CreditManager.py
7=================
8
9Credit module.
10
11Note that there is no standard credit implementation.
12You must implement your own but the CreditManager class provides a hook
13to do this with.
14
15"""
16
17# Import python standard library modules
18import sys, os
19
20# Import local modules
21from serverConfig import UNRESTRICTED_CREDIT
22
23class CreditManager:
24    """
25    Credit manager class - requires your code for implementation.
26    The basic version only gives an example of the types of
27    calls that might be used.
28    """
29    def __init__(self, username, sessionObj):
30        """
31        Initialises the instance defining instance variables
32        """
33        self.username=username
34        self.bag=sessionObj
35
36    def creditCheck(self):
37        """
38        Returns either a string saying that the user has not got
39        enough credit to do the task or a 1 for success.
40        """
41        if UNRESTRICTED_CREDIT==1: return 1
42        jobCosts={"bread":3, "size":1, "colour":0}
43       
44        choice1=self.bag.option1
45        jobCost=jobCosts[choice1]
46       
47        userCredit={"rod":1, "jane":5, "freddie":0, "zippy":10}
48        f=open("/tmp/OUT", "w") ; f.write("%s\n" % self.username) ; f.close()
49        if userCredit[self.username]>=jobCost:
50            return 1
51        else:
52            return "User does not have sufficient credit to perform this task."
53           
Note: See TracBrowser for help on using the repository browser.