Forum OpenACS Q&A: User designed database package for dot?


Has dotLrn some package for user designed databases
anybody has / is working in something like that?


Posted by Nima Mazloumi on
Jose, we are currently working on a generic package on top of XoTCL that will provide an XoTCL layer for acs objects. This package also provides a UI for defining Objects and Relations and provide autogeneration for forms and lists. Thus it will be easy to create user defined packages that basically are for data storage and retrieval. The package is conform to Viennas xotcl CR layer and we also provide cached objects. What we are currently working on is to provide an XoTCL layer for common acs objects like users, persons, authorities, community,...
Hi, Nima!

Thanks for your answer.
Have you any code to test?


Posted by Vinod Kurup on
Hi Jose,

There is also a package in OpenACS called dynamic-types which provides a TCL API and a minimal UI to create acs-object-types. It also provides the ability to dynamically create forms to go along with those object types.

The version in OpenACS has been cleaned up and improved (I think by Lee Denison at xargs). I've been working with this version.

Here's how I would create a new type:

set otype institution

# create a new dynamic object type
dtype::create -name $otype \
    -supertype acs_object \
    -pretty_name "Institution" \
    -pretty_plural "Institutions" \
    -table_name institutions \
    -id_column institution_id
Create attributes:
# create attributes
dtype::create_attribute -name institution_name \
    -object_type $otype \
    -datatype text \
    -pretty_name "Institution Name" \
    -pretty_plural "Institution Names"

dtype::create_attribute -name state \
    -object_type $otype \
    -datatype text \
    -pretty_name "State" \
    -pretty_plural "States"
Create a form with elements to match the attributes.
# create form
set form_id [dtype::form::create]
dtype::form::map_type -form_id $form_id \
    -form standard \
    -object_type $otype

# create elements
set element_id [dtype::form::add_element -form_id $form_id \
                    -element institution_name \
                    -widget text]
array set attr [dtype::get_attribute -object_type $otype -name institution_name]
dtype::element::map_attribute -element_id $element_id \
    -attribute_id $attr(attribute_id)

set element_id [dtype::form::add_element -form_id $form_id \
                    -element state \
                    -widget select]
array unset attr
array set attr [dtype::get_attribute -object_type $otype -name state]
dtype::element::map_attribute -element_id $element_id \
    -attribute_id $attr(attribute_id)
dtype::element::add_parameter -element_id $element_id \
    -param options \
    -value [db_list_of_lists get_states "select state_name, abbrev from us_states"]
Notice in that last case that you can prepopulate the select list by setting the 'options' parameter. There are a bunch of other parameters that you can set/edit, all based on standard form builder functionality.

Now here's the add.tcl page:

ad_page_contract {

    @author Vinod Kurup
    @creation-date 2006-06-17
} {

set context [list "Add Institution"]

dtype::form::generate \
    -dtype_form standard \
    -object_type institution \
    -ats_form add

if { [template::form::is_valid add] } {
    dtype::form::process -ats_form add
    ad_returnredirect ./
and the ADP file
<property name="context">@context@</property>

<formtemplate id="add"></formtemplate>
Again, all of this can be done in TCL (as above), or via a web UI. The part I haven't figured out is if it's possible to build up pages which query the system automatically, but it's easy enough to build those with the list-builder. Wiki page: