source: DataExtractor/trunk/dx-0.1.0/request.py @ 70

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/DataExtractor/trunk/dx-0.1.0/request.py@70
Revision 70, 1.4 KB checked in by astephen, 16 years ago (diff)

Beta-release of dx: version 0.1.0

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1"""
2request.py
3===========
4
5Request module for the extractor package.
6
7This module holds the Requestdb class that is used
8to store the contents of user requests.
9
10Version history
11===============
12
13Version 1.0:  - 01/03/2004
14              - Ag Stephens, British Atmospheric Data Centre.
15              - First version.
16
17"""
18
19# Import required modules
20
21import os
22import shelve
23
24# Set Global variables
25
26from shared_data import *
27
28class Requestdb:
29 
30    # An instance of this holds a user request
31    # (for one field only at present).
32
33    def __init__(self, request_id=None):
34        if request_id==None:
35            pid=os.getpid()
36            request_id="request_%s" % pid
37        self.id=request_id
38        self.dict={"request_id":request_id}
39   
40    def getRequestID(self):
41        return self.id
42       
43    def getNumDatasets(self):
44        return self.num_datasets
45
46    def readRequest(self):
47        dict_obj={}
48        shelve_obj=shelve.open(os.path.join(request_dir, self.id))
49        for key in shelve_obj.keys():
50             dict_obj[key]=shelve_obj[key]
51        shelve_obj.close()
52        return dict_obj
53
54    def writeRequest(self, request):
55        shelve_obj=shelve.open(os.path.join(request_dir, self.id))
56        for key in request.keys():
57            shelve_obj[key]=request[key]
58        return
59
60    def loadRequest(self):
61        pass
62
63    def saveRequest(self):
64        pass
Note: See TracBrowser for help on using the repository browser.