Forum OpenACS Q&A: Re: Some tips about XoTcl development best practices

Collapse
Posted by Antonio Pisano on
Ok, about the last issue it was something weird happening because of copy/paste, forget about it.

Related to my real application, I have a column which should be a postGIS GEOGRAPHY data type (a gps location). Can I define such column from xotcl? This code

::xo::db::Class create ::cic::Location -superclass ::xo::db::Object -slots {
foreach slot {name street number zone region country} {
::xo::db::Attribute create $slot
}
::xo::db::Attribute create location ­datatype GEOGRAPHY(POINT,4326)
}

complains about "datatype GEOGRAPHY(POINT,4326)" not being defined.

Can I define new datatypes?

Collapse
Posted by Antonio Pisano on
Another thing I am interested into is the right workflow when upgrading the data model: I have tried defining a class like this

::xo::db::Class create ::cic::Location -superclass ::xo::db::Object -slots {
::xo::db::Attribute create name
::xo::db::Attribute create street
::xo::db::Attribute create number
::xo::db::Attribute create zone
::xo::db::Attribute create region
}

Then I have modified the definition so it could include other columns like this

::xo::db::Class create ::cic::Location -superclass ::xo::db::Object -slots {
::xo::db::Attribute create name
::xo::db::Attribute create street
::xo::db::Attribute create number
::xo::db::Attribute create zone
::xo::db::Attribute create region
::xo::db::Attribute create country
::xo::db::Attribute create category -datatype integer -references categories(category_id)
}

The definition seems correct, and issuing the command in the shell returns the previously created object type, but the new fields are not added to the data model. What is the right way to do that?