Forum OpenACS Development: contraint: one object type per package

I created a new package and its datamodel and I faced the following issue

ERROR: duplicate key value violates unique constraint "acs_object_types_pkg_name_un"

Could anyone tell me the reason why I must create only one object_type for package?

Let's say one possible example: in a CRM system I have one package that creates the datamodel for two object_types: loan and lead

Why couldn't I create two object_type related to only one package?

Cheers,

Collapse
Posted by Dave Bauer on
Pacakage in the object type definiton refers to Oracle PL/SQL package where you can organize functions and procedures under a namespace. This is generally the same name as the object type.

In postgresql it would be the same as the first half of the function names before the double underscore.

Collapse
Posted by Iuri Sampaio on
1) In this case, would leads and loans obligatory be objects of the same object type?

Sorry but that doesn't make sense. They have different attributes moreover they are different objects. In my head they should have different object_types as well.

2) Must I write them on different packages?
That doesn't feel the best way to go either.

Collapse
Posted by Dave Bauer on
You should define the pl/sql package name in the object type uniquely.

You can put these definitions in the same OpenACS package. The package-key is not the same as the package_name in the object type.

Collapse
Posted by Iuri Sampaio on
Dave,

I have questions on what would be the pl/sql package.
I created the pl/sql functions based on the tables i wrote to the package.

I.E.
1) Package: lead-management

2) Tables: lm_leads, lm_loans

3) pl/sql functions:

lm_lead__new, lm_lead__delete
lm_load__new, lm_loan__delete

That's why i want to create two object types

Anyway,
I already started to read
https://openacs.org/doc/apm-design.html

*ps. there are broken links, I already counted 4. I let you know

Collapse
Posted by Dave Bauer on
Use the object_type as the package_name.

That is how the function names are contructed

ie:

{object_type}__function is the same as
{package_name}__function

Check out some of the existing object types to see.

It is totally unrelated to the OpenACS package name/package_key unless by coincidence the package_key is the same as the object_type.

Collapse
Posted by Iuri Sampaio on
Thanks Dave,
I will see what I can do to use object_type as the package name. Plus, I will have a look and follow the examples.

By the way, I buildt this datamodel looking at acs-subsite and acs-kernel SQL's files.

Mainly, it was the datamodel for persons, parties and acs_objects

Furthermore, I am reading docs and I found a broken link that would describe to me more concepts about pl/sql packages. Here it is bellow

At page https://openacs.org/doc/apm-design.html

in the API block there is the paragraph:

Authoring a Package

Full instructions on how to prepare an OpenACS package are available in Packages. The API here can be invoked manually by a package's data model creation script, but need not to be used. This API is part of the APM PL/SQL package.

The broken link is

https://openacs.org/api-doc/plsql-subprogram-one?type=PACKAGE&name=APM

Cheers,

Collapse
Posted by Dave Bauer on
Yes thanks for the broken link report, but remember every copy of OpenACS contains the full documentation. You can use the local copy in your install.