Forum OpenACS Development: Re: How OpenACS coding could get its groove back

Collapse
Posted by Tom Jackson on

Just a note about query-writer: it applies to any database table. If the primary key refers to the acs_object table, you can use it to create new object types. Differences from the cr include the fact that you write down your data model: a real table with real constraints. A wizard is used to create the information necessary for query-writer to work. You just supply the table name and the primary key. You don't have to write any tcl or pl code in order to define your object type, that is one reason it is called query-writer! Once you have an object defined in query-writer you can use a tcl api to create new objects:


set object_array(title) $title
set object_array(content) $content

# create the object:

qw_new object_name object_array

Of course you wouldn't even need to do that if you use the supplied url api. This page, called qw.tcl takes form variables and processes them to create a series of qw_* statements. Processing includes running filters you specify on each attribute, and the newest version uploads files, runs multi-attribute filters and allows other callbacks to be executed. So for instance, the above title and content would probably come from a form. The form (this is all you would need to write) could be:


<form action=/qw/qw method=post>
<input type=hidden name=return_url value=@some_url@>

<input type=text name=new.object_name.title.1>
<br \>
<textarea name=new.object_name.content.1 ></textarea>

</form>

So once you have setup the object in query-writer, you can turn over the form entry design to someone else without worrying about them messing around with tcl and database stuff.

Granted, I still believe query-writer is difficult to get used to, and if you have a small data model, one or two tables, it probably isn't worth the hassle, this is the way with most tools.