Module EDSession
[hide private]
[frames] | no frames]

Source Code for Module EDSession

 1  # -*- coding: utf8 -*- 
 2  # 
 3  #    Project: The EDNA Kernel 
 4  #             http://www.edna-site.org 
 5  # 
 6  #    File: "$Id:$" 
 7  # 
 8  #    Copyright (C) 2008-2009 European Synchrotron Radiation Facility 
 9  #                            Grenoble, France 
10  # 
11  #    Principal authors: Jérôme Kieffer (jerome.kieffer@esrf.fr) 
12  #  
13  # 
14  #    This program is free software: you can redistribute it and/or modify 
15  #    it under the terms of the GNU Lesser General Public License as published 
16  #    by the Free Software Foundation, either version 3 of the License, or 
17  #    (at your option) any later version. 
18  # 
19  #    This program is distributed in the hope that it will be useful, 
20  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
21  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
22  #    GNU Lesser General Public License for more details. 
23  # 
24  #    You should have received a copy of the GNU General Public License 
25  #    and the GNU Lesser General Public License  along with this program.   
26  #    If not, see <http://www.gnu.org/licenses/>. 
27  # 
28  __authors__ = [ "Jérôme Kieffer" ] 
29  __contact__ = "jerome.kieffer@esrf.fr" 
30  __license__ = "LGPLv3+" 
31  __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" 
32  __date__ = "27/05/2011" 
33   
34  import os, time 
35  from EDObject import EDObject 
36  from EDVerbose import EDVerbose 
37 38 -class classproperty(property):
39 - def __get__(self, obj, type_):
40 return self.fget.__get__(None, type_)()
41 - def __set__(self, obj, value):
42 cls = type(obj) 43 return self.fset.__get__(None, cls)(value)
44
45 -class EDSession(EDObject):
46 """ 47 keep track on a temporary zone writable (/buffer at ESRF, /scratch elsewhere, ...) 48 """ 49 _sessionId = None 50 51 @classmethod
52 - def getSessionId(cls):
53 """getter for session ID""" 54 if cls._sessionId is None: 55 cls._sessionId = time.strftime("%Y%m%d-%H%M%S") 56 return cls._sessionId
57 58 @classmethod
59 - def setSessionId(cls, idSession):
60 """setter for session ID. Only valid if not yet set !!!!""" 61 if cls._sessionId is None: 62 cls._sessionId = idSession 63 else: 64 EDVerbose.ERROR("You are not allowed to change the session ID !!!!")
65 sessionId = classproperty(getSessionId, setSessionId)
66