Forum OpenACS Development: Re: Title before name_method

Collapse
Posted by Antonio Pisano on
Dear Malte,

I think "downgrading" the name method was not intentional and would be actually better to have an approach similar to your suggestion.

Will let you know shortly

Collapse
Posted by Antonio Pisano on
Mmm, needs a bit of thinking:

first of all, according to the git history, this behavior is much older than the reform you have been referring to. The reform in acs_object__name prioritizing the title instead of the name method is some 21 years old: https://github.com/openacs/openacs-core/blame/719a4a4fe58dd082e7dccfaed805125337b10d41/packages/acs-kernel/sql/postgresql/acs-objects-create.sql#L767-L774

Similarly, the behavior concerning the title in acs_object__new is also quite old: https://github.com/openacs/openacs-core/blame/719a4a4fe58dd082e7dccfaed805125337b10d41/packages/acs-kernel/sql/postgresql/acs-objects-create.sql#L492-L502

In current codebase, for the name method to trigger, the object's title must be null. This won't happen automatically, given that we always fallback to the object type's pretty name + id. We could change that , e.g. let the title be null when not specified explicitly.

Another approach is to switch the priority when we retrieve the name, e.g. name method first and object title as a fallback.

Personally, I tend to prefer the first approach: we would store less data for those use cases where the object's title is not important, keep current behavior if the object's title matter, and give the name method a fair chance to trigger.

I am open to discussion, but as this has the potential to be a breaking change, we should consider if it should make it into the release or not.

Ciao

Collapse
Posted by Gustaf Neumann on
let the title be null when not specified explicitly.

Malte: would this help for PO? i.e., does PO set the title attribute and uses the object.name method on the same entities? Does this happen just on PO-specific acs_object_types?

Collapse
Posted by Malte Sussdorff on
let the title be null when not specified explicitly.

Yes. this would help indeed. Though this would have to propagate through the acs_object.new function, which sets a default title.

Then the order would make sense - Use title if set, use object.name otherwise.

We would need an upgrade script which resets the title to "null" if the title is the default name set by acs_objects.new

Collapse
Posted by Malte Sussdorff on
I dug around in project-open code and found that project-open overwrote the acs_object__name function, so uncomment the part where it first looks at the name method. Probably 21 years ago 😊.

Either way, we should avoid a breaking change. Therefore we could have an upgrade script which:

- Changes acs_object.new to not set a default title
- Delete the title wherever the title = default title

Two options
- Set the name method to a new method which preserves the old "default" behavior, (e.g. acs_object.default_title) where the name_method is empty, and make name_method mandatory. This will make it very clear which naming method is used, if title is not overwritten.
- Change the acs_object.name method to default to the old default title if the title is NULL and the name_method is NULL.

Collapse
Posted by Gustaf Neumann on
What is the state of this? Any progress?
Is this the only known blocker of ProjectOpen to use OpenACS 5.10.1?