Forum OpenACS Q&A: creating ETP applications

Collapse
Posted by Sandhya Subash on
Hi All, I am doing my first project with OpenACS and creating a ETP
application that follows Docbook Schema DTD. I found while reading
the code that news,faq,default are examples of ETP applications and
news, faq are packages as well. Also there is a procedure that
etp::define_application which lets you to create ETP applications.
But I want to find out which file is this procedure called from....
Is it /sql or /tcl directory.

My understanding is that I need to create a new package called Book
and I decided to have the following Content Items

Create a bookinfo has attributes
title,
author,
copyright,
edition ,
pubdate

Create a chapter has attr
title,
para

create a section has attr
title ,
para

create a subsection has attr
title ,
para

I think I have to create tables to store bookinfo, chapter, section,
subsection
create table bookinfo( book_info_id integer,
owner_id integer,
creation_user ,
creation_date,
last_modified,
title varchar(255),
author varchar,
copyright varchar,
edition varchar,
pubdate date

similar tables for chapter, section, subsection with their respective
attributes.

Please give me feedback on the above data model. This is my
understanding so far.

Thanks Sandhya

Collapse
Posted by Gregory McMullan on

Ah! A question I can sort of answer!

I have recently been learning how to use ETP myself, so I may not know the best practices, but this works for me. In /web/myserver/packages/edit-this-page/tcl/etp-init.tcl I call etp::define_content_type and etp::define_application. etp::define_application lets you set where, relative to /web/myserver, you place your .tcl and .adp files that display your pages.

I have to go to bed now, so I can't comment on your data model at this time, but you might find my WP presentation about what I have learned about developing with ETP helpful. It's at https://openacs.org/wp/display/501/ and comments are welcome.

Collapse
Posted by Dave Bauer on
Sandhya,

You don't need a seperate pacakge. The News and FAQ packages are unrelated to Edit-This-Page. ETP just happens to have application implementations that are similar to News and FAQ. Basically it shows you that you can quickly create a new application without programming an entire package.

Greg is right. The examples of etp::define_application are in etp-init.tcl. That is probably the easiest place to defien your new application. Init files are only sourced on startup, so after changing this file, you need to restart the server before the changes will take effect.

Now, from you description of the data model, ETP might not be for you. It is a replacement for one-table applications. It looks like you need  at least 3 tables, or 3 different content types, which will have to be contained in each other. ETP does not handle this type of situation currently. You will want to use the content repository. There are ways to define content types that are contained in other content types. You can restrict which content-types can be children of a certain type. For example, book is a content type that can contain chapter objects. A chapter can contain section objects. I would make sections able to contain other section objects, and remove the seperate subsection type. So subsection would be a section object with another section as a parent instead of a chapter.

Ok, this is a lot to digest. I suggest reading this documentation:
http://dev.openacs.org/doc/acs-content-repository/ (note: this link will break at some point)
especially this part: http://dev.openacs.org/doc/acs-content-repository/guide/object-relationships.html

and if you have any more questions, please ask them here.