Forum OpenACS Development: Updated xotcl packages + more oo version of the notes example

Hi Folks,

here is an improved the xotcl packages and added functionality for a generic handling of cr-items with classes and subclasses. Essentially, one can generate the data model (object-type, views, tables, queries) by defining an instance of CrClass. The following two statements (from xotcl-note/tcl/note-data-model-procs.tcl) generate a CrNote and a subclass of CrNote named CrSubNote (which has one attribute more) with its relevant tables during startup, if these do not exist already.

::Generic::CrClass create CrNote \
    -pretty_name "Note" -pretty_plural "Notes" \
    -table_name "generic_cr_note" -id_column "note_id" 
  
::Generic::CrClass create CrSubNote -superclass CrNote \
    -pretty_name "SubNote" -pretty_plural "SubNotes" \
    -table_name "generic_cr_subnote" -id_column "subnote_id" \
    -sql_attributes {{number integer}}
The www/index.tcl file contains in essence the following fragment, through which a listing of the existing instances of CrNote and CrSubNote and edit buttons can be obtained.
::Generic::List index \
    -object_type CrNote \
    -with_subtypes true \
    -object_types {CrNote CrSubNote} \
    -fields {
      EDIT {}
      title {label "Title"}
      object_type {label "Object Type"}
      DELETE {}
    }

index generate -order_by title
The editing magic in www/edit.tcl using ad_form is hidden by:
::Generic::Form form1 \
    -object_type CrNote \
    -fields {
      {item_id:key}
      {title:text {label Title}}
      {description:text,optional {label Description}}
      {number:text {label Number}}
      {text:richtext(richtext),optional {label Content}}
    }

form1 generate
Some admin functionality is provided in the admin/ directory.

Alltogether, these simple classes can be used to

  • create and delete the schema
  • add, edit, delete instances
  • provide a polymorphic listing (containing content repository items of different types) where the appropriate editing forms are choosen based on the object type)
i haved placed the ::Generic:: classes into xotcl-core (in tcl/generic-procs.tcl), since these have to be loaded before the application package (here: xotcl-note).

This package serves mostly as programming example but might be useful for simple kind of applications already. i have developed and tested it with dotlrn 2.1.3b. It can be dowloaded from: http://media.wu-wien.ac.at/download/xotcl-note-0.2.apm

Please, obtain as well the updated version of xotcl-core for this. If you have not installed xotcl yet, but you want to try this out, please read: http://media.wu-wien.ac.at/download/README-xotcl-oacs. Below is as well an improved version of the request monitor.