Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Public Attributes
arcom.store.stringstore.StringStore Class Reference
Inheritance diagram for arcom.store.stringstore.StringStore:
Inheritance graph
[legend]
Collaboration diagram for arcom.store.stringstore.StringStore:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def get
def set
def list
def lock
def unlock

Public Attributes

 datadir
 non_existent_object
 llock

Detailed Description

Class for storing string objects. 

Definition at line 9 of file stringstore.py.


Constructor & Destructor Documentation

def arcom.store.stringstore.StringStore.__init__ (   self,
  storecfg,
  non_existent_object = {} 
)
Constructor of PickleStore.

PickleStore(storecfg)

'storecfg' is an XMLNode with a 'DataDir'
'non_existent_object' will be returned if an object not found

Reimplemented from arcom.store.picklestore.PickleStore.

Definition at line 12 of file stringstore.py.

00012 
00013     def __init__(self, storecfg, non_existent_object = {}):
00014         """ Constructor of PickleStore.
00015 
00016         PickleStore(storecfg)
00017 
00018         'storecfg' is an XMLNode with a 'DataDir'
00019         'non_existent_object' will be returned if an object not found
00020         """
00021         PickleStore.__init__(self, storecfg, non_existent_object)
00022         log.msg(arc.VERBOSE, "StringStore constructor called")
00023         log.msg(arc.VERBOSE, "datadir:", self.datadir)


Member Function Documentation

def arcom.store.stringstore.StringStore.get (   self,
  ID 
)
Returns the object with the given ID.

get(ID)

'ID' is the ID of the requested object.
If there is no object with this ID, returns the given non_existent_object value.

Reimplemented from arcom.store.picklestore.PickleStore.

Definition at line 24 of file stringstore.py.

00024 
00025     def get(self, ID):
00026         """ Returns the object with the given ID.
00027 
00028         get(ID)
00029 
00030         'ID' is the ID of the requested object.
00031         If there is no object with this ID, returns the given non_existent_object value.
00032         """
00033         try:
00034             # generates a filename from the ID
00035             # then use pickle to load the previously serialized data
00036             return eval(file(self._filename(ID),'rb').read())
00037         except IOError:
00038             # don't print 'file not found' if there is no such ID
00039             pass
00040         except EOFError:
00041             # TODO: find out what causes this problem
00042             pass
00043         except:
00044             # print whatever exception happened
00045             log.msg()
00046             log.msg(arc.ERROR, "filename:", self._filename(ID))
00047         # if there was an exception, return the given non_existent_object
00048         return copy.deepcopy(self.non_existent_object)

Here is the call graph for this function:

Here is the caller graph for this function:

def arcom.store.picklestore.PickleStore.list (   self) [inherited]
List the IDs of the existing entries.

list()

Returns a list of IDs.

Reimplemented in arcom.store.cachedpicklestore.CachedPickleStore.

Definition at line 63 of file picklestore.py.

00063 
00064     def list(self):
00065         """ List the IDs of the existing entries.
00066         
00067         list()
00068         
00069         Returns a list of IDs.
00070         """
00071         IDs = []
00072         # get all the filenames
00073         for name in self._list():
00074             try: # decode the filename
00075                 ID = base64.b64decode(name)
00076                 IDs.append(ID)
00077             except:
00078                 log.msg()
00079         return IDs

Here is the call graph for this function:

def arcom.store.basestore.BaseStore.lock (   self,
  blocking = True 
) [inherited]
Acquire the lock.

lock(blocking = True)

'blocking': if blocking is True, then this only returns when the lock is acquired.
If it is False, then it returns immediately with False if the lock is not available,
or with True if it could be acquired.

Reimplemented in storage.ahash.replicatedahash.ReplicationStore.

Definition at line 27 of file basestore.py.

00027 
00028     def lock(self, blocking = True):
00029         """ Acquire the lock.
00030 
00031         lock(blocking = True)
00032 
00033         'blocking': if blocking is True, then this only returns when the lock is acquired.
00034         If it is False, then it returns immediately with False if the lock is not available,
00035         or with True if it could be acquired.
00036         """
00037         return self.llock.acquire(blocking)

Here is the caller graph for this function:

def arcom.store.stringstore.StringStore.set (   self,
  ID,
  object 
)
Stores an object with the given ID..

set(ID, object)

'ID' is the ID of the object
'object' is the object itself
If there is already an object with this ID it will be overwritten completely.

Reimplemented from arcom.store.picklestore.PickleStore.

Definition at line 49 of file stringstore.py.

00049 
00050     def set(self, ID, object):
00051         """ Stores an object with the given ID..
00052 
00053         set(ID, object)
00054 
00055         'ID' is the ID of the object
00056         'object' is the object itself
00057         If there is already an object with this ID it will be overwritten completely.
00058         """
00059         if not ID:
00060             raise Exception, 'ID is empty'
00061         try:
00062             # generates a filename from the ID
00063             fn = self._filename(ID)
00064             tmp_fn = self._tmpfilename(ID)
00065             # if 'object' is empty, don't make file
00066             if object:
00067                 # serialize the given list into tmp_fn
00068                 f = file(tmp_fn,'wb')
00069                 f.write(str(object))
00070                 f.close()
00071                 # try to rename the file
00072                 try:
00073                     os.rename(tmp_fn,fn)
00074                 except:
00075                     # try to create parent dir first, then rename the file
00076                     os.mkdir(os.path.dirname(fn))
00077                     os.rename(tmp_fn,fn)
00078             elif os.path.isfile(fn):
00079                 # object empty, file is not needed anymore
00080                 os.remove(fn)
00081         except:
00082             log.msg()

Here is the call graph for this function:

Here is the caller graph for this function:

def arcom.store.basestore.BaseStore.unlock (   self) [inherited]
Release the lock.

unlock()

Reimplemented in storage.ahash.replicatedahash.ReplicationStore.

Definition at line 38 of file basestore.py.

00038 
00039     def unlock(self):
00040         """ Release the lock.
00041 
00042         unlock()
00043         """
00044         self.llock.release()
        

Here is the caller graph for this function:


Member Data Documentation

Definition at line 18 of file basestore.py.

Definition at line 25 of file basestore.py.

Definition at line 20 of file basestore.py.


The documentation for this class was generated from the following file: