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

Collapse
Posted by Antonio Pisano on
The tutorial is great, thanks! Would you mind linking this pages in http://www.openacs.org/xowiki/ ? I don't have permissions for that...

What about the xotcl equivalents for db_1row, db_list etc? My guess is ::xo::db::Driver, is that right?

Collapse
Posted by Antonio Pisano on
Another thing I use a lot for big-size tables is pagination by template::list construct in procedural api (defining page_query, rows_per_page etc).

Is there an equivalent in xotcl for paginated results?

Collapse
Posted by Antonio Pisano on
In the meantime I am going through the tutorial and I am facing an issue:

when pasting this code from tutorial into a file in the tcl folder of my package, I am getting an error

::xo::db::Class create ::demo::Person ­-superclass ::xo::db::Object ­-slots {
::xo::db::Attribute create name ­column_name pname
::xo::db::Attribute create age ­default 0 ­datatype integer
::xo::db::Attribute create projects ­default {} ­multivalued true
}

the error is

wrong # args: should be "init"
::demo::Person ::xo::db::Class->init
::demo::Person ::xotcl::Object->residualargs
::xo::db::Class ::xotcl::Class->create

What could that be?

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?