Roger Lovelock wrote: > I tried to do that initially by copying the pattern of code from the > AppWizard to the ClassDesigner, but found that there was no method > immediately available in Bizobj to load the definition from a DataStructure. > Obviously it must be able to be done, but at this stage of my knowledge I > felt it would probably take me a lot of research to find out how so I didn't > pusue it.
You can find the used datatypes here: http://dabodev.com/wiki/DataTypes And here is an example for a bizobj: class PerBizobj(dabo.biz.dBizobj): def initProperties(self): self.Caption = "Per" self.DataSource = "PER" self.KeyField = "iid" # Setting the DataStructure explicitly here is optional, but recommended as # it will keep Dabo from interpreting field types from the backend every # time. It lets you specify what types you expect which fields to be. Also, # this information is used in self.setSQL() to add the fields to the query. # (field_alias, field_type, pk, table_name, field_name, field_scale) self.DataStructure = ( ("iid", "N", True, "PER", "iid"), ("tod_date", "D", False, "PER", "tod_date"), ("gebname", "M", False, "PER", "gebname"), ("titel", "M", False, "PER", "titel"), ("e_land", "N", False, "PER", "e_land"), ("e_fam", "N", False, "PER", "e_fam"), ("beruf", "M", False, "PER", "beruf"), ("jnp_iid", "N", False, "PER", "jnp_iid"), ) # Use the DefaultValues dict to specify default field values for new # records. By default DefaultValues is the empty dict, meaning that # no default values will be filled in. #self.DefaultValues['<field_name>'] = <value_or_function_object> self.DefaultValues['tod_date'] = None # Default encoding is set to utf8, but if your backend db encodes in # something else, you need to set that encoding here (or in each # bizobj individually. A very common encoding for the Americas and # Western Europe is "latin-1", so if you are getting errors but are # unsure what encoding to pick, try uncommenting the following line: self.Encoding = 'UTF-8' def afterInit(self): self.DataSource = "PER" self.KeyField = "iid" self.addFrom("per") self.addField("per.iid") self.addField("per.tod_date") self.addField("per.gebname") self.addField("per.titel") self.addField("per.e_land") self.addField("per.e_fam") self.addField("per.beruf") self.addField("per.jnp_iid") def setBaseSQL(self): # Set up the base SQL (the fields clause, the from clause, etc.) The # UI refresh() will probably modify the where clause and maybe the # limit clause, depending on what the runtime user chooses in the # select page. self.addFrom("PER") self.setLimitClause("500") #self.addFieldsFromDataStructure() def validateRecord(self): """Returning anything other than an empty string from this method will prevent the data from being saved. """ ret = "" # Add your business rules here. return ret And here is the DDL for the corresponding Firebird table: CREATE TABLE PER ( IID Numeric(18,0) NOT NULL, CRESTAMP Timestamp, CREUSER Varchar(100), UPDSTAMP Timestamp, UPDUSER Varchar(100), TOD_DATE Date, GEBNAME Varchar(100), TITEL Varchar(100), E_LAND Integer, E_FAM Integer, BERUF Varchar(100), JNP_IID Numeric(18,0) NOT NULL, PRIMARY KEY (IID) ); ALTER TABLE PER ADD FOREIGN KEY (JNP_IID) REFERENCES JNP (IID); I hope this helps, Uwe _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]
