def create(self, name): """Create the model and its resource.""" self._register_resource(name) GlobalClass.create(self, name) self.template = resource_template name = "Mysql4_" + name # We prepend this string so _create_class() # will create a directory called "Mysql4" # in the Model/ directory. self._create_class(name, "Mage_Core_Model_Mysql4_Abstract")
def _register_resource(self, name): """Tell Mage that the module has one or more resource models.""" GlobalClass.register(self) tag = self.module.name.lower() group = self.config.xpath(self.xpath + "/" + tag)[0] group_mysql4 = group.tag + "_mysql4" resource_model = find_or_create(group, "resourceModel") resource_model.text = group_mysql4 group_mysql4 = find_or_create(group, group_mysql4) class_ = find_or_create(group_mysql4, "class") class_.text = "%s_%s_%s_Mysql4" % (self.module.namespace, self.module.name, self.type) entities = find_or_create(group_mysql4, "entities") name_lower = find_or_create(entities, name.lower()) table = find_or_create(name_lower, "table") table.text = self.table or group.tag + "_" + name_lower.tag self.put_config(self.config)
def __init__(self, superclass=None, override=False, table=None, id_field_name=None): GlobalClass.__init__(self, superclass, override) self.table = table self.id_field_name = id_field_name