Forum OpenACS Development: query-writer -- eliminating pl functions

I'm working on my 'essentially unused by anyone but me' package query-writer. It is annoying to use this package, because even though it writes all the basic pl code for the package so you can create/drop the package, plus the new/update/delete functions, you have to use a poorly designed UI to configure everything, which is also time consuming and mind numbing.

Anyway, I thought, I'm writing pl based on data stored in nsv's, why can't I just write tcl procs that do the same thing through dml statements instead?

The current query-writer is pretty basic. Object packages have to be directly derived from acs_objects, so it was pretty easy to change the query-writer to do what I wanted, I just replaced one proc (for the __new function writer). I also wrote a tcl proc to create an acs_object, that is acs_object::new.

This should make things pretty simple for upgrading/developing packages. When the datamodel changes, you just add the new field, and restart the server. You don't need to edit and fiddle with the updated pl functions.

Does this sound like a useful way to go? The big benefit is in the update pl code. This is kind of hackish in the first place. Each attribute had to be tested to see if it was not null, then independently updated, creating a bunch of wasted space for every update. The new dml update would be very efficient compared to using functions. Also the 16 parameter limit will go away for individual functions, although query-writer could handle 32 attributes overlapping any number of functions.

Collapse
Posted by Randy O'Meara on
Tom, is this package still alive? Could I peek?

Thanks,

Randy

Collapse
Posted by Tom Jackson on

Randy,

I'll package up what I have. I did several upgrades:

  • Wizard install. You just give the table name of the acs_object and it grabs all the information from the database for the object attributes.
  • Almost no pl -- I have eliminated most pl, even though this was auto-generated anyway, and actually it still is, if you want to define the function signatures. What I did was to create a tcl procedure to create/update/delete the acs_objects table. Then an auto-generated tcl procedure calls this proc create the acs_object, then uses regular dml to insert data into the object table. Updates are regular dml to the object table, or through the acs_object::update function, same for deletes. I do create one function the object__object_p function, since it doesn't need a signature. The big benefit of a tcl api, is that when I upgrade the data model, I only need to add the new attributes (to the qw data model). I don't need to regenerate the pl functions, drop and reload.

But I think you might find it difficult to learn, no documentation. If you have a lot of data model to deal with, it should be alright, but for a few object tables, maybe more trouble than it is worth in its current state.

As an example, it probably takes me less than a half hour from the point the object table is ready, until all the api is finished.

I'll post the link here.

Collapse
Posted by Randy O'Meara on
Thank you, Tom. Please don't do any extra work on my behalf.

Randy

Collapse
Posted by Tom Jackson on

Randy: The query-writer package is here. Try version 0.6.0.

Collapse
Posted by Randy O'Meara on
Tom, thanks for taking the time to package this up. All of the links to the various versions of query-writer except 0.6.0 work. The link to 0.6.0 results in...
Not Found
The requested URL was not found on this server.

AOLserver/3.5.1 on http://tumbleweed.rmadilo.com
Collapse
Posted by Tom Jackson on

Oops, sorry, wrong permissions. Try now.

Collapse
Posted by Randy O'Meara on
Cool. Thanks.