Forum OpenACS Q&A: Re: Development Tutorial Available

Collapse
Posted by Ola Hansson on
Joel,

You'd use "package_instantiate_object" from a library proc that in this case ought to be called "samplenote::new" and ought to exist in a file named "samplenote/tcl/samplenote-procs.tcl" (see https://openacs.org/api-doc/proc-view?proc=forum::new&source_p=1 for an example from "forums").

This should go after creating the datamodel but before you describe how to write web pages, I think.

IMO we should almost always aim towards mirroring a package's PL[PG]SQL API in a Tcl API - as OF did throughout the forums package for instance (Thanks for teaching us that too, Ben!). Besides taking slightly longer to write a package, promoting this approach in general will not only result in reusable code (saves a lot of .xql file writing because queries in .xql files can't be reused in different places - it is not recommended, at least) but will also yeild code that's easier to read and has better self-documentation available from the Api Browser.

Whether this should be reflected in the basic tutorial or in  the advanced section, I don't know... Presumably we'd want all packages to be written as similar to one another as possible, stylewise. So it would probably be better to teach this as part of the general/basic package development section ... What do others think?

Oh yes, I found one small thing; every occurrence of "timestamp" should be changed to "timestamptz" which is an alias for "timestamp with timezone" (which should not be used IIRC).

/Ola