Forum OpenACS Development: Response to Too lazy to code

Collapse
Posted by Tom Jackson on
The way I understand it, a package that has been developed by using the query-writer will depend on the query-writer being installed (and bootstrapped with qw-dumps from my package) on any system that wants to run the new package. Is that correct?

Yes, correct. What it should mean is that users install query-writer like a regular package using the package manager. You must have done this. :)

If so, qw-made packages won't run on a basic install of OpenACS as of today. In that case I reckon developers will be reluctant to write packages using qw until/unless it is added as a core OpenACS package. Hmm. I guess Oracle support will be required for this to happen...

Yes, I have been talking with Don about doing this. It apparently needs Oracle support, so query-writer needs to be ported to Oracle. That should be easy for insert/update/delete queries, as the query-writer uses itself in most places, but select queries need porting using .xql files. However, there are packages in the system that haven't been ported one way or the other, and some that have, have bugs. This is one package that must be ported perfectly, otherwise the benefits of using it go way down.

I don't think it should be a core package any time soon, just available from cvs so it is easy to develop to completion. When, or if it goes in to cvs isn't my decision.

Nonetheless, I think the qw comes in handy even when it's just used as a generator of create/drop scripts for ones objects - it's a good way to enforce consistency among the .sql files (and developers) IMO. I take it you have developed packages of your own (merchant-system?) with the qw. Do you have plans to release such a package so that others may study how it uses the qw? Also, have you noticed any major negative side effects performance or otherwise?

If you need a copy of merchant-system, I can give you a link. It works for my client, but needs changes to remove vendor specific info. It is a good place to look to find out how the query-writer can be used. Merchant-system is now pushing 450+ files, without any query processing files, imagine if I had .xql files everywhere!

Query-writer is especially helpful if you have a large data model, but it also helps administer access to attributes, and even to the values certain table attributes can be set to by a particular user. The original query-writer was written for an Oracle system, but only the query processing part, it didn't need to know about overloaded functions, default values or attribute order. It also didn't have a tcl api that could be used, only the http post method was supported.

What is left out, and needs to be added in is a set of *_p tcl vars set to 0 or 1. They take the form: object_attribute_value_group_p, or something like that. group being the qw_group, not an OACS group. They are useful in writing adp templates that keep in sync with attribute values that are allowed in a certain situation, so select boxes can only contain values the user can set, or input boxes for attributes can be set to not show up if a user can't access that attribute. Also, I had a confirm page which weeded out vars which didn't change on an update form. This used a similar set of form vars that started with 'cur.' Right now, every var is updated each time. Another thing to consider is the method of updating the database. Every non-null attribute is updated separately, instead of togeather as in a simple dml statement. However, I have not noticed any performance problems with query-writer. Most of the functions are performed on nsv_ arrays, and performance can be increased by adding more nsv buckets.

Before porting to Oracle, I think the query-writer needs to become more feature complete. Otherwise the job will be much greater. However, the port of query-writer will greatly speed porting any package using query-writer. That is the big benefit, all you will have to port will be select statements.

BTW, I've hacked "www/admin/objects/pg-create.tcl" so that it outputs the table creation and I fixed the indentations (using forums as model) and a few other things. I can email you the whole file or a patch if you want, after I've tested it a bit further.

That sounds great! You can send me a copy when you get time.