def __init__(self, filename, database_name, module, instancevars): self.filename = filename self.database_name = database_name file_text = Utility.readURL(filename) newvars = {} exec file_text in vars(module), newvars for name, value in newvars.items(): setattr(self, name, value) self.parent = None if not hasattr(self, 'instance'): self.instance = [] for attr in instancevars+('parent',): if not hasattr(self, attr): setattr(self, attr, []) if attr not in self.instance: self.instance.append(attr) attributes = vars(self).items() attributes.sort(lambda a, b: cmp(a[0], b[0])) for name, object in attributes: if hasattr(object, 'is_instance_var'): if name not in self.instance: self.instance.append(name) object.parent = self object.name = name if hasattr(object, 'object_list'): getattr(self, object.object_list).append(object)
def __init__(self, filename, database_name, module, instancevars): self.filename = filename self.database_name = database_name file_text = Utility.readURL(filename) newvars = {} six.exec_(file_text, vars(module), newvars) for name, value in newvars.items(): setattr(self, name, value) self.parent = None if not hasattr(self, 'instance'): self.instance = [] for attr in instancevars + ('parent', ): if not hasattr(self, attr): setattr(self, attr, []) if attr not in self.instance: self.instance.append(attr) attributes = vars(self).items() attributes.sort(lambda a, b: cmp(a[0], b[0])) for name, object in attributes: if hasattr(object, 'is_instance_var'): if name not in self.instance: self.instance.append(name) object.parent = self object.name = name if hasattr(object, 'object_list'): getattr(self, object.object_list).append(object)
def createObject(self, newvars): file_text = Utility.readURL(self.filename) exec file_text in vars(self.environment), newvars
def createObject(self, newvars): file_text = Utility.readURL(self.filename) exec file_text in vars(self.environment), newvars