Forum OpenACS Q&A: Attribute creation

Collapse
Posted by Caroline Meeks on
I'm trying to understand the code for acs_attributes.

attribute::add creates an additional column in the table for that object_type based on table_name in acs_object_types.

Why? Is there supposed to be a trigger ceated somewhere that populates this column automatically?

This does not seem to match the way dotLRN uses attributes

dotlrn_community::set_attribute inserts a value in acs_attribute_values.

Why is this a dotLRN proc? Is there a core proc that sets attribute values?

To retrive attribute values dotLRN seems to cache a list of attribute values for each community and access it through a tcl API rather then views.

Based on the dotLRN code it seems like adding a column when you add an attribute is wrong, but perhaps it is necessary for CMS?

Collapse
2: Re: Attribute creation (response to 1)
Posted by Jeff Davis on
Here is what the documentation for attribute::add (which lives in acs-subsite) says:
wrapper for the acs_attribute.create_attribute  call. Note that this procedure assumes type-specific storage.
It adds a column to the type specific table whereas dotlrn_community::set_attribute is setting an attribute for a specific object_id (and I think uses a generic table).

Whether you use a generic table or a type specific table is sort of an implementation issue and the right decision depends a little on how sparse the attribute values are, how many rows there are in the type specific table and so on. neither is really right or wrong.

also both functions are in the wrong place. acs-subsite and dotlrn both have a lot of generic code that belongs elsewhere.