Forum OpenACS Q&A: Using the new xotcl db layer

Collapse
Posted by Nima Mazloumi on
Hi,

I tried:

set c [::xo::db::Class get_class_from_db -object_type person]

which results in the following error:

superclass: expected a list of classes but got '::xo::db::party' during '::xo::db::person superclass'

Any idea? I am using the latest code from HEAD.

Thanks,
Nima

Collapse
Posted by Gustaf Neumann on
Person is defined in OpenACS as subtype of party. The method "get_class_from_db" creates a single class from the acs_type definition in the database, and reflects the same subtype relationship as in the OpenACS type table in XOTcl. The message says, that ::xo::db::party is tried to be used as a superclass of ::xo::db::person, but party is not defined as a class yet.

In order to use person, one has to load party first.

See for example:
http://alice.wu-wien.ac.at:8000/s5-xotcl-core-tutorial/presentation?slideshow=1&pagenr=44

Collapse
Posted by Malte Sussdorff on
Wouldn´t it make sense to have get_class_from_db automatically initialize the superclasses if they don´t exist as this is probably what you want to do (most of the time) and provide it with a flag like "-no_superclasses" ?
Collapse
Posted by Gustaf Neumann on
It is certainly possible to implement a method, that creates all classes in sight (it is not a question of initializing), but still, it is necessary to a method to create a single class. For real world applications one might wish to keep these classes in the blueprint. Therefore it is necessary to keep control over deleting these classes after the connection thread or not. By working with the classes, one will recognize that the attributes tables of OpenACS are for many typs not complete. Therefore it is necessary to add the missing attributes manually (look for an example into 06-param-procs). So, get_class_from_db is just a helper method..

I don't understand what you mean by "no superclasses", since the superclasses are not optional.