Forum OpenACS Development: an intriguing development relief

Collapse
Posted by Iuri Sampaio on
Hi there,

I am gonna tell quick example that explains a little bit of why I see OACS development as a very frustrating, complex and intriguing system to understand and it demands a very good amount of time to learn it
. Nevertheless I also think OACS as the best stuff (in all aspects) I have worked with and I really hope I stay on it.

I am building up a system using OACS framework. I decided to use bugtracker package because it has so many functionalities that i need to use and it would save very much of my time to implement it by myself.
So BT just fits perfectly to what I aimed to build. I meant almost perfect except for one very little detail:

a bug has an attribute called component, which everyone who knows bt pkg is aware of it. (if i can call it as an attribute!)

Then i need to create a new attribute attached to component as sort of dependent of it. So i called subcomponent.

Furthemore, I want to use the whole code already written on BT (TCL pages and its APIs) and just add subcomponent in the respective places.

I tracked down the whole process of adding a new bug in the system. The starting point is at bug-add.tcl, ad_form -name bug,
more specifically in the API:



bug_tracker::bug::new \

-bug_id $bug_id \

-package_id $package_id \

-component_id $component_id \

-subcomponent_id $subcomponent_id \

-found_in_version $found_in_version \

-summary $summary \

-description [template::util::richtext::get_property contents $description] \

-desc_format [template::util::richtext::get_property format $description] \

-keyword_ids $keyword_ids \

-fix_for_version $fix_for_version \

-assign_to $role_resolver

which has its source code at page /tcl/bug-procs.tcl

from this API, another API is called. That is bug_tracker::bug::insert, which is in the same TCL page /tcl/bug-procs.tcl



set bug_id [bug_tracker::bug::insert \

-bug_id $bug_id \

-package_id $package_id \

-component_id $component_id \

-subcomponent_id $subcomponent_id \

-found_in_version $found_in_version \

-summary $summary \

-description $description \

-desc_format $desc_format \

-user_agent $user_agent \

-user_id $user_id \

-ip_address $ip_address \

-item_subtype $item_subtype \

-content_type $content_type \

-fix_for_version $fix_for_version ]

which also calls another API oacs_util::vars_to_ns_set at /tcl/bug-procs.tcl



oacs_util::vars_to_ns_set \

-ns_set $extra_vars \

-var_list { bug_id package_id component_id subcomponent_id found_in_version summary user_agent comment_content comment_format creation_date fix_for_version assign_to}

as you can see i added the new field "subcomponents" at all those APIs as a parameter. As well as all the others parameters that are already there.

then i created the new column on the table bt_bugs :.
alter table bt_bugs add column subcomponent_id integer

I restarted aolserver, plus i have put ns_logs to certify the new parameter was properly passed through
the APIs

After all this, the changes I have made didn't work successfully

So i remove all the stuff I amended and I just created a line of code at bug-add.tcl after the API bug_tracker::bug::new , which is:

db_dml set_subcomponent_id { UPDATE bt_bugs SET subcomponent_id = :subcomponent_id where bug_id = :bug_id }

Although this solution is not even close to be elegant, it worked pretty good as I expected.

I know the issue is much more complex and I am aware that what i have mentioned here in this brief history involves dozens of different subjects and concepts about the theme.

Furthermore it is very much probable that someone will come up with an answer of a simple line of command such as the solution i wrote.

The bottom line is that the best answer is with time and experience (headaches and frustration) on OACS i will figure out those obstacles.

Those were just my reflexive thoughts.
Thanks in advance for reading my relief

Collapse
Posted by Dave Bauer on
Bugtracker is probably one of the most complex packages to attempt to modify in OpenACS.

It looks like you got pretty close, but you probably just need to debug a little more closely exactly how the data gets inserted into the database.

Just adding the new parameter won't affect unless you find the query that actually does the insert and also change that.

Also note for objects you don't want ot just add a column to the table, you need to create the object type attribute, in this case I believe bugtracker uses the content repository.

Collapse
Posted by Iuri Sampaio on
yes i understand a new object type attribute needs to be created

I saw there is this admin section:
admin/object-types/one?object_type=bt_bug

then how do i create the new object type attribute?

Collapse
Posted by Claudio Pasolini on
Hi Iuri,

the canonical way to add an attibute to a content item is the 'content_type__create_attribute' API, which takes care of adding the column to the related table too.

Regarding bug-tracker I find it frustrating and unnecessarily complicated.

Collapse
Posted by Brian Fenton on
Hi Iuri,

I feel your pain, OpenACS is not easy to pick up for beginners. I think you probably solved 95% of the problem - one part I think you're probably missing is the actual Insert and Update statements. The part that always gets me (STILL!) is the xql files - sometimes you'll see 2 very similar queries, one in the .tcl and the other in the .xql. Usually I change the wrong file, and then spend 10 minutes swearing because my query is not working. 😊

It's all part of the learning curve of using a powerful piece of software. You're in "Black Belt" territory now. 😉

Never feel afraid to ask questions here on the forum - I know sometimes they are quiet, but there are plenty of people watching.

best wishes
Brian