Package slumMaya :: Module slumNode
[hide private]
[frames] | no frames]

Source Code for Module slumMaya.slumNode

 1  # 
 2  # slumNode -  classNode that evaluates the slum class stored in a node and 
 3  #                         makes its object available as self.slum 
 4  # 
 5  #    Copyright (C) 2008 - Roberto Hradec 
 6  # 
 7  # --------------------------------------------------------------------------- 
 8  #        This file is part of SLUM. 
 9  # 
10  #    SLUM is free software: you can redistribute it and/or modify 
11  #    it under the terms of the GNU General Public License as published by 
12  #    the Free Software Foundation, either version 3 of the License, or 
13  #    (at your option) any later version. 
14  # 
15  #    SLUM is distributed in the hope that it will be useful, 
16  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
17  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
18  #    GNU General Public License for more details. 
19  # 
20  #    You should have received a copy of the GNU General Public License 
21  #    along with SLUM.  If not, see <http://www.gnu.org/licenses/>. 
22  # ------------------------------------------------------------ 
23   
24   
25  from classNode import * 
26  import slum 
27   
28  global slumNodeCache 
29  slumNodeCache={} 
30   
31 -class slumNode(classNode):
32 ''' 33 derivated from classNode, this class adds the advantage of evaluating an slum attribute automaticaly, if 34 one is present in a node. 35 Instead of returning the string value of the slum attribute, it returns the evaluated class object 36 from the code in the string attribute. 37 '''
38 - def __init__(self, node, data=None, forceSlumEval = False):
39 classNode.__init__(self, node, data) 40 self.classe = None 41 if classNode.has_key(self, 'slum'): 42 self.classe = classNode.__getitem__(self,'slum') 43 classNode._dict.__setitem__(self.classe, 'edited', False) 44 self.evalSlumClass( forceSlumEval )
45 - def evalSlumClass(self, forceSlumEval = False):
46 if self.classe: 47 48 if not slumNodeCache.has_key(self.node) or forceSlumEval: 49 slumNodeCache[self.node] = slum.evalSlumClass(self.classe['code'], self.classe['name']) 50 51 self.slum = slumNodeCache[self.node] 52 self.slumParameters = self.slum.parameters()
53 54 # check if file md5 matches the one stored in the node. 55
56 - def updated(self):
57 ''' 58 check if source code has being updated. 59 ''' 60 return slum.checkMD5(self.classe['md5'], slum.path( self.classe['name'] ) )
61