Author: bugman Date: Sun Jun 22 19:05:45 2008 New Revision: 6430 URL: http://svn.gna.org/viewcvs/relax?rev=6430&view=rev Log: Converted the mod_attr list into a class variable. Modified: 1.3/data/align_tensor.py Modified: 1.3/data/align_tensor.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/align_tensor.py?rev=6430&r1=6429&r2=6430&view=diff ============================================================================== --- 1.3/data/align_tensor.py (original) +++ 1.3/data/align_tensor.py Sun Jun 22 19:05:45 2008 @@ -590,34 +590,8 @@ class AlignTensorData(Element): """An empty data container for the alignment tensor elements.""" - def __init__(self, name): - """Function for placing the tensor name in the class namespace.""" - - self.name = name - - - def __setattr__(self, name, value): - """Function for calculating the parameters, unit vectors, and tensors on the fly. - - @param name: The name of the object to set. - @type name: str - @param value: The value to set the object corresponding to the name argument to. - @type value: Any Python object type - """ - - # Get the base parameter name and determine the object category ('val', 'err', or 'sim'). - if search('_err$', name): - category = 'err' - param_name = name[:-4] - elif search('_sim$', name): - category = 'sim' - param_name = name[:-4] - else: - category = 'val' - param_name = name - - # List of modifiable attributes. - mod_attr = ['name', + # List of modifiable attributes. + __mod_attr__ = ['name', 'Sxx', 'Syy', 'Sxy', @@ -632,8 +606,34 @@ 'domain', 'red'] + def __init__(self, name): + """Function for placing the tensor name in the class namespace.""" + + self.name = name + + + def __setattr__(self, name, value): + """Function for calculating the parameters, unit vectors, and tensors on the fly. + + @param name: The name of the object to set. + @type name: str + @param value: The value to set the object corresponding to the name argument to. + @type value: Any Python object type + """ + + # Get the base parameter name and determine the object category ('val', 'err', or 'sim'). + if search('_err$', name): + category = 'err' + param_name = name[:-4] + elif search('_sim$', name): + category = 'sim' + param_name = name[:-4] + else: + category = 'val' + param_name = name + # Test if the attribute that is trying to be set is modifiable. - if not param_name in mod_attr: + if not param_name in self.__mod_attr__: raise RelaxError, "The object " + `name` + " is not modifiable." # Set the attribute normally.